Skip to content

Add runtime regex check to prevent SyntaxError on older browsers#8353

Merged
iHiD merged 1 commit intomainfrom
fix-regex-lookbehind-detection
Feb 8, 2026
Merged

Add runtime regex check to prevent SyntaxError on older browsers#8353
iHiD merged 1 commit intomainfrom
fix-regex-lookbehind-detection

Conversation

@iHiD
Copy link
Copy Markdown
Member

@iHiD iHiD commented Feb 8, 2026

Summary

  • Fixes SyntaxError: Invalid regular expression: invalid group specifier name reported on /journey (and likely other pages)
  • The isLookbehindSupported() function uses UA sniffing which can incorrectly return true for browsers that don't support lookbehinds (e.g. in-app WebViews, Chrome on old iOS using WebKit). This causes highlight.ts to load highlightjs-roc, which contains regex literals with lookbehind assertions, triggering a fatal parse-time SyntaxError
  • Adds the existing areAllRegExpFeaturesSupported() runtime check (which was previously unused) as the first guard in isLookbehindSupported(), so even when UA detection fails the runtime check catches it

Test plan

  • yarn test passes (all failures are pre-existing @bugsnag/js module resolution issues)
  • On a browser without lookbehind support: areAllRegExpFeaturesSupported() returns falseisLookbehindSupported() returns falselazyHighlightAll() exits early → highlight.ts never loaded → no parse error

🤖 Generated with Claude Code

…n older browsers

The UA-based isLookbehindSupported() can return true for unrecognized
browsers (e.g. in-app WebViews, Chrome on old iOS using WebKit), causing
highlight.ts to load highlightjs-roc which contains regex literals with
lookbehind assertions. This triggers a fatal SyntaxError during module
parsing on browsers that don't support lookbehinds.

Adding areAllRegExpFeaturesSupported() as a runtime check before UA
sniffing ensures the guard works correctly even when UA detection fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iHiD iHiD requested a review from dem4ron as a code owner February 8, 2026 14:49
@iHiD iHiD merged commit e3d7c7d into main Feb 8, 2026
41 checks passed
@iHiD iHiD deleted the fix-regex-lookbehind-detection branch February 8, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant