Skip to content

Commit

Permalink
{fix} correctly handle very high code points
Browse files Browse the repository at this point in the history
  • Loading branch information
bgotink committed Mar 31, 2024
1 parent 55b1f11 commit 35786e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/string-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function removeEscapedWhitespace(value) {
export function replaceEscapes(value) {
return value.replaceAll(escape, (escape, unicode) => {
if (unicode) {
return String.fromCharCode(parseInt(unicode, 16));
return String.fromCodePoint(parseInt(unicode, 16));
} else {
const replacement = escapedValues.get(escape);

Expand Down
13 changes: 13 additions & 0 deletions test/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import assert from "node:assert/strict";
import {test} from "uvu";

import {parse} from "../src/index.js";

test("\\u escapes", () => {
assert.equal(
parse(String.raw`"\u{10abcd}"`, {as: "value"}).value,
String.fromCodePoint(0x10abcd),
);
});

test.run();

0 comments on commit 35786e1

Please sign in to comment.