diff --git a/tabby-linkifier/src/api.ts b/tabby-linkifier/src/api.ts index 05b1a768..f42c327b 100644 --- a/tabby-linkifier/src/api.ts +++ b/tabby-linkifier/src/api.ts @@ -13,4 +13,12 @@ export abstract class LinkHandler { } abstract handle (uri: string, tab?: BaseTerminalTabComponent): void + + private _fullMatchRegex: RegExp | null = null + get fullMatchRegex (): RegExp { + if (!this._fullMatchRegex) { + this._fullMatchRegex = new RegExp(`^${this.regex.source}$`) + } + return this._fullMatchRegex + } } diff --git a/tabby-linkifier/src/decorator.ts b/tabby-linkifier/src/decorator.ts index 4c16b1e6..50ae8a57 100644 --- a/tabby-linkifier/src/decorator.ts +++ b/tabby-linkifier/src/decorator.ts @@ -31,7 +31,7 @@ export class LinkHighlighterDecorator extends TerminalDecorator { const openLink = async uri => { for (const handler of this.handlers) { - if (!handler.regex.test(uri)) { + if (!handler.fullMatchRegex.test(uri)) { continue } if (!await handler.verify(await handler.convert(uri, tab), tab)) {