Skip to content

Commit

Permalink
Work around Bun parser bug (fixes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Nov 17, 2024
1 parent 964fa4b commit a595f61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ function getCharEscape(codePoint, {isAfterBackref, inCharClass, useFlagV}) {
) {
// Don't convert codePoint `0` to `\0` since that's corruptible by following literal digits
return codePoint > 0xFF ?
r`\u{${codePoint.toString(16).toUpperCase()}}` :
r`\x${codePoint.toString(16).toUpperCase().padStart(2, '0')}`;
`\\u{${codePoint.toString(16).toUpperCase()}}` :
`\\x${codePoint.toString(16).toUpperCase().padStart(2, '0')}`;
}
const escapeChars = inCharClass ?
(useFlagV ? CharClassEscapeCharsFlagV : CharClassEscapeChars) :
Expand Down
2 changes: 1 addition & 1 deletion src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const FirstPassVisitor = {
// `emojiRegex` is more permissive than `\p{RGI_Emoji}` since it allows over/under-qualified
// emoji using a general pattern that matches any Unicode sequence following the structure of
// a valid emoji. That actually makes it more accurate for matching any grapheme
const emoji = minTargetEs2024 ? r`\p{RGI_Emoji}` : emojiRegex().source.replace(/\\u\{/g, r`\x{`);
const emoji = minTargetEs2024 ? r`\p{RGI_Emoji}` : emojiRegex().source.replace(/\\u\{/g, `\\x{`);
// Close approximation of an extended grapheme cluster. Details: <unicode.org/reports/tr29/>.
// Skip name check to allow `RGI_Emoji` through, which Onig doesn't support
replaceWith(parseFragment(r`(?>\r\n|${emoji}|\P{M}\p{M}*)`, {skipPropertyNameValidation: true}));
Expand Down

0 comments on commit a595f61

Please sign in to comment.