diff --git a/src/utils/index.ts b/src/utils/index.ts index 9b88e46..1ff6cf9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,13 +4,26 @@ export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false; export const generateProjectFromDevSites = (siteUrl: string): string | null => { const url = new URL(siteUrl); - const githubUrls = ['github.com', 'github.dev']; - for (const githubUrl of githubUrls) { - if (url.host === githubUrl) { + + // Github + const githubHosts = ['github.com', 'github.dev']; + for (const host of githubHosts) { + if (url.host === host) { // input: https://github.com/wakatime/browser-wakatime?tab=readme-ov-file#development-instructions // output: browser-wakatime return url.pathname.split('/')[2] || null; } } + + // Gitlab + const gitlabHosts = ['gitlab.com']; + for (const host of gitlabHosts) { + if (url.host === host) { + // input: https://gitlab.com/wakatime/browser-wakatime?tab=readme-ov-file#development-instructions + // output: browser-wakatime + return url.pathname.split('/')[2] || null; + } + } + return null; };