Skip to content

Commit 2da59a8

Browse files
committed
Externalizes SourceHut path detection regex
1 parent 989c8c8 commit 2da59a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

htmlpreview.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
};
8484

8585
const RE_GITLAB_PATH = /^\/[^/]+\/.+\/(-\/)?(blob|raw)\/[^/]+/;
86+
const RE_SOURCEHUT_PATH = /^\/~[^/]+\/[^/]+\/(tree|blob)\/[^/]+/;
8687

8788
/**
8889
* Extracts the forge software and host,
@@ -124,7 +125,7 @@
124125
software = FORGE_SOFTWARES.ForgeJo;
125126
host = FORGE_HOSTS.CodeBerg_org;
126127
} else if (url.host == 'git.sr.ht'
127-
&& (/^\/~[^/]+\/[^/]+\/(tree|blob)\/[^/]+/).test(url.pathname)) {
128+
&& RE_SOURCEHUT_PATH.test(url.pathname)) {
128129
software = FORGE_SOFTWARES.SourceHut;
129130
host = FORGE_HOSTS.Git_Sr_Ht;
130131
}

0 commit comments

Comments
 (0)