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 <cursoragent@cursor.com>
This commit is contained in:
@@ -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('');
|
||||
|
||||
Reference in New Issue
Block a user