Skip to content

Commit

Permalink
Merge pull request #283 from v1ack/master
Browse files Browse the repository at this point in the history
Support self-hosted GitLab, get GitLab repo name from subgroups
  • Loading branch information
alanhamlett authored Oct 9, 2024
2 parents 0b0d61c + 87e57c0 commit 77d0963
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,21 @@ const GitHub: HeartbeatParser = (url: string) => {
};

const GitLab: HeartbeatParser = (url: string) => {
const match = url.match(/(?<=gitlab\.com\/[^/]+\/)([^/?#]+)/);
const match = url.match(/([^/]+)(?:\/-\/|\/?$)/);
if (!match) return;

const urlRepo = match[1];
const repoName = document.querySelector('body')?.getAttribute('data-project-full-path');
if (!repoName || repoName.split('/')[1] !== match[0]) {
const isValidPath = repoName?.split('/').pop() === urlRepo;
if (!isValidPath) {
return {
language: '<<LAST_LANGUAGE>>',
};
}

return {
language: '<<LAST_LANGUAGE>>',
project: match[0],
project: urlRepo,
};
};

Expand Down Expand Up @@ -368,7 +370,7 @@ const SITES: Record<KnownSite, SiteParser> = {
},
gitlab: {
parser: GitLab,
urls: [/^https?:\/\/(.+\.)?gitlab.com\//],
urls: [/^https?:\/\/(.+\.)?gitlab.[\w.]+\//],
},
googlemeet: {
parser: GoogleMeet,
Expand Down

0 comments on commit 77d0963

Please sign in to comment.