summaryrefslogtreecommitdiff
path: root/source/libs/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r--source/libs/utils.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index a4629fca..0d9ca856 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -204,3 +204,10 @@ export function getLatestVersionTag(tags: string[]): string {
return latestVersion;
}
+
+const escapeRegex = (string: string) => string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
+export const prCommitRegex = new RegExp(`\\b${escapeRegex(location.origin)}[/][^/]+[/][^/]+[/]pull[/]\\d+[/]commits[/][0-9a-f]{7,40}\\b(?! \\]|\\))`, 'gi');
+
+export function preventPrCommitLinkBreak(comment: string) {
+ return comment.replace(prCommitRegex, '[$& ]($&)');
+}