From e0c34ef7bc21c39d635d92ad7bc38c69e183316d Mon Sep 17 00:00:00 2001 From: Eugene Date: Sat, 24 May 2025 15:19:43 +0200 Subject: [PATCH] fixed #10482 - duplicate browser tab opening when clicking a link with an IP in it --- tabby-linkifier/src/api.ts | 8 ++++++++ tabby-linkifier/src/decorator.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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)) {