Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function getDecodedEntity(
: parseInt(entity.substr(2));

decodeResult =
decodeCode >= 0x10ffff
decodeCode > 0x10ffff
? outOfBoundsChar
: decodeCode > 65535
? fromCodePoint(decodeCode)
Expand Down
9 changes: 9 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ describe('lib', () => {
expect(decode(entity)).toEqual(value);
}
});
it('should decode the maximum code point U+10FFFF instead of replacing it', () => {
const maxCodePoint = String.fromCodePoint(0x10ffff);
expect(decode('')).toEqual(maxCodePoint);
expect(decode('')).toEqual(maxCodePoint);
// round-trip: encode emits a reference that decode must read back
expect(decode(encode(maxCodePoint, {mode: 'nonAscii'}))).toEqual(maxCodePoint);
// code points past the Unicode range stay replaced
expect(decode('�')).toEqual(String.fromCharCode(65533));
});
});
});

Expand Down