File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -268,12 +268,16 @@ export function legacyHookDecode(input, fallbackEncoding) {
268268 if ( enc === 'utf-8' ) return utf8toStringLoose ( u8 )
269269 if ( enc === 'utf-16le' ) return utf16toStringLoose ( u8 , 'uint8-le' )
270270 if ( enc === 'utf-16be' ) return utf16toStringLoose ( u8 , 'uint8-be' )
271- if ( ! Object . hasOwn ( labels , enc ) || enc === 'replacement' ) throw new RangeError ( E_ENCODING )
271+ if ( ! Object . hasOwn ( labels , enc ) ) throw new RangeError ( E_ENCODING )
272272
273273 if ( multibyteSet . has ( enc ) ) {
274274 if ( ! createMultibyteDecoder ) throw new Error ( E_MULTI )
275275 return createMultibyteDecoder ( enc , true ) ( u8 )
276276 }
277277
278+ // https://encoding.spec.whatwg.org/#replacement-decoder
279+ // On non-streaming non-fatal case, it just replaces any non-empty input with a single replacement char
280+ if ( enc === 'replacement' ) return input . byteLength > 0 ? replacementChar : ''
281+
278282 return createSinglebyteDecoder ( enc , true ) ( u8 )
279283}
You can’t perform that action at this time.
0 commit comments