Skip to content

Commit aef994d

Browse files
committed
Unifies GitLab path detection regex
1 parent 603e049 commit aef994d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

htmlpreview.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
return rawifyForgeUrl(previewFileUrl);
8282
};
8383

84+
const RE_GITLAB_PATH = /\/[^/]+\/.+\/(-\/)?|raw\/[^/]+/;
85+
8486
/**
8587
* Extracts the forge software and host,
8688
* the given a URL that points to a file on a known git forge.
@@ -105,11 +107,11 @@
105107
software = FORGE_SOFTWARES.BitBucket;
106108
host = FORGE_HOSTS.BitBucket_org;
107109
} else if (url.host == 'gitlab.com'
108-
&& (/\/[^/]+\/.+\/(-\/)?raw\/[^/]+/).test(url.pathname)) {
110+
&& RE_GITLAB_PATH.test(url.pathname)) {
109111
software = FORGE_SOFTWARES.GitLab;
110112
host = FORGE_HOSTS.GitLab_com;
111113
} else if (url.host == 'lab.allmende.io'
112-
&& (/\/[^/]+\/.+\/(-\/)?raw\/[^/]+/).test(url.pathname)) {
114+
&& RE_GITLAB_PATH.test(url.pathname)) {
113115
software = FORGE_SOFTWARES.GitLab;
114116
host = FORGE_HOSTS.Lab_Allmende_io;
115117
} else if (url.host == 'codeberg.org'

0 commit comments

Comments
 (0)