From 682ebc9f1c45933c3d49df44ff118c2bc7b6415b Mon Sep 17 00:00:00 2001 From: Jeremy Walker Date: Sun, 8 Feb 2026 14:33:44 +0000 Subject: [PATCH] Add runtime check to isLookbehindSupported() to prevent SyntaxError on 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 --- app/javascript/utils/regex-check.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/utils/regex-check.ts b/app/javascript/utils/regex-check.ts index 7b348c95a4..9f6f77123d 100644 --- a/app/javascript/utils/regex-check.ts +++ b/app/javascript/utils/regex-check.ts @@ -37,6 +37,8 @@ function compareVersions(versionA: string, versionB: string): number { } export function isLookbehindSupported(): boolean { + if (!areAllRegExpFeaturesSupported()) return false + const parser = new UAParser().getBrowser() switch (parser.name) {