Skip to content

Commit

Permalink
fix: error handling unicode characters containing a 9
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Jan 6, 2023
1 parent d1f0dd1 commit d665ec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/jsonrepair.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ describe('jsonRepair', () => {
strictEqual(jsonrepair('"\u2605"'), '"\u2605"')
strictEqual(jsonrepair('"😀"'), '"😀"')
strictEqual(jsonrepair('"\ud83d\ude00"'), '"\ud83d\ude00"')
strictEqual(jsonrepair('"йнформация"'), '"йнформация"')
})

it('supports escaped unicode characters in a string', () => {
strictEqual(jsonrepair('"\\u2605"'), '"\\u2605"')
strictEqual(jsonrepair('"\\ud83d\\ude00"'), '"\\ud83d\\ude00"')
strictEqual(
jsonrepair('"\\u0439\\u043d\\u0444\\u043e\\u0440\\u043c\\u0430\\u0446\\u0438\\u044f"'),
'"\\u0439\\u043d\\u0444\\u043e\\u0440\\u043c\\u0430\\u0446\\u0438\\u044f"'
)
})

it('supports unicode characters in a key', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/stringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const codeAcuteAccent = 0x00b4 // ´

export function isHex(code: number): boolean {
return (
(code >= codeZero && code < codeNine) ||
(code >= codeZero && code <= codeNine) ||
(code >= codeUppercaseA && code <= codeUppercaseF) ||
(code >= codeLowercaseA && code <= codeLowercaseF)
)
Expand Down

0 comments on commit d665ec2

Please sign in to comment.