From 9ae115165b6f2b4cd1aea5893399ea29768241c5 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Wed, 5 May 2021 23:24:13 +0200 Subject: [PATCH] Fix greedy regex which was also affecting href in tags --- source/app/web/statics/about/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/app/web/statics/about/script.js b/source/app/web/statics/about/script.js index 04a46c5e..4a04ff71 100644 --- a/source/app/web/statics/about/script.js +++ b/source/app/web/statics/about/script.js @@ -61,15 +61,15 @@ const baseUrl = String.raw`https?:\/\/(?:www\.)?github.com\/([\w.-]+\/[\w.-]+)\/` return value .replace( - RegExp(baseUrl + String.raw`(?:issues|pull|discussions)\/(\d+)(?:\?\S+)?(#\S+)?`, "g"), + RegExp(baseUrl + String.raw`(?:issues|pull|discussions)\/(\d+)(?:\?[\w-]+)?(#[\w-]+)?(?=<)`, "g"), (_, repo, id, comment) => (options?.repo === repo ? "" : repo) + `#${id}` + (comment ? ` (comment)` : ""), ) // -> 'lowlighter/metrics#123' .replace( - RegExp(baseUrl + String.raw`commit\/([\da-f]+)`, "g"), + RegExp(baseUrl + String.raw`commit\/([\da-f]+)(?=<)`, "g"), (_, repo, sha) => (options?.repo === repo ? "" : repo + "@") + sha, ) // -> 'lowlighter/metrics@123abc' .replace( - RegExp(baseUrl + String.raw`compare\/(\S+...\S+)`, "g"), + RegExp(baseUrl + String.raw`compare\/([\w-.]+...[\w-.]+)(?=<)`, "g"), (_, repo, tags) => (options?.repo === repo ? "" : repo + "@") + tags, ) // -> 'lowlighter/metrics@1.0...1.1' }