Skip to content

Commit e3d7c7d

Browse files
iHiDclaude
andauthored
Add runtime check to isLookbehindSupported() to prevent SyntaxError on older browsers (#8353)
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>
1 parent 48f09bf commit e3d7c7d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

app/javascript/utils/regex-check.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function compareVersions(versionA: string, versionB: string): number {
3737
}
3838

3939
export function isLookbehindSupported(): boolean {
40+
if (!areAllRegExpFeaturesSupported()) return false
41+
4042
const parser = new UAParser().getBrowser()
4143

4244
switch (parser.name) {

0 commit comments

Comments
 (0)