extract project name from gitlab
This commit is contained in:
@@ -4,13 +4,26 @@ export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;
|
|||||||
|
|
||||||
export const generateProjectFromDevSites = (siteUrl: string): string | null => {
|
export const generateProjectFromDevSites = (siteUrl: string): string | null => {
|
||||||
const url = new URL(siteUrl);
|
const url = new URL(siteUrl);
|
||||||
const githubUrls = ['github.com', 'github.dev'];
|
|
||||||
for (const githubUrl of githubUrls) {
|
// Github
|
||||||
if (url.host === githubUrl) {
|
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
|
// input: https://github.com/wakatime/browser-wakatime?tab=readme-ov-file#development-instructions
|
||||||
// output: browser-wakatime
|
// output: browser-wakatime
|
||||||
return url.pathname.split('/')[2] || null;
|
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;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user