From 6d1f12cb7b70e7da8f3739025947ae5d5efe03e3 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 May 2026 22:08:25 -0700 Subject: [PATCH] fix(web-links): avoid duplicate g flag when cloning url regex LinkComputer rebuilt the search RegExp with (regex.flags || '') + 'g', which throws if the caller already passed a global regex. Only append g when it is not already present in regex.flags. Co-authored-by: Cursor --- addons/addon-web-links/src/WebLinkProvider.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/addon-web-links/src/WebLinkProvider.ts b/addons/addon-web-links/src/WebLinkProvider.ts index 0a826eb3a..5df5d268a 100644 --- a/addons/addon-web-links/src/WebLinkProvider.ts +++ b/addons/addon-web-links/src/WebLinkProvider.ts @@ -57,7 +57,8 @@ function isUrl(urlString: string): boolean { export class LinkComputer { public static computeLink(y: number, regex: RegExp, terminal: Terminal, activate: (event: MouseEvent, uri: string) => void): ILink[] { - const rex = new RegExp(regex.source, (regex.flags || '') + 'g'); + const flags = regex.flags.includes('g') ? regex.flags : `${regex.flags}g`; + const rex = new RegExp(regex.source, flags); const [lines, startLineIndex] = LinkComputer._getWindowedLineStrings(y - 1, terminal); const line = lines.join('');