diff --git a/src/index.js b/src/index.js index ae3db0d..5eea7c8 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ import 'string.fromcodepoint'; * \U([0-9A-Fa-f]+) - sixth alternative; matches the 8-digit hexadecimal escape sequence used by python (\U0001F3B5) * ) */ -const jsEscapeRegex = /\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\U([0-9A-Fa-f]{8})/g; +const jsEscapeRegex = /\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\\U([0-9A-Fa-f]{8})/g; const usualEscapeSequences = { '0': '\0', diff --git a/test/index.js b/test/index.js index 017324c..c854df1 100644 --- a/test/index.js +++ b/test/index.js @@ -41,6 +41,6 @@ test('avoids double unescape cascade', t => { }); test('python hex escape sequences', t => { - t.is(unescapeJs('---\U000000A9---'), '---\u00A9---'); - t.is(unescapeJs('---\U0001F3B5---'), '---\uD83C\uDFB5---'); + t.is(unescapeJs('---\\U000000A9---'), '---\u00A9---'); + t.is(unescapeJs('---\\U0001F3B5---'), '---\uD83C\uDFB5---'); });