Răsfoiți Sursa

fixed #10482 - duplicate browser tab opening when clicking a link with an IP in it

Eugene 4 luni în urmă
părinte
comite
e0c34ef7bc
2 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 8 0
      tabby-linkifier/src/api.ts
  2. 1 1
      tabby-linkifier/src/decorator.ts

+ 8 - 0
tabby-linkifier/src/api.ts

@@ -13,4 +13,12 @@ export abstract class LinkHandler {
     }
 
     abstract handle (uri: string, tab?: BaseTerminalTabComponent<any>): void
+
+    private _fullMatchRegex: RegExp | null = null
+    get fullMatchRegex (): RegExp {
+        if (!this._fullMatchRegex) {
+            this._fullMatchRegex = new RegExp(`^${this.regex.source}$`)
+        }
+        return this._fullMatchRegex
+    }
 }

+ 1 - 1
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)) {