-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Git slug - support generic SSH URL patterns
- Loading branch information
Showing
2 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
const { extractRepoSlug } = require('../utils'); | ||
const { getSlugFromGitURL } = require('../utils'); | ||
|
||
describe('Utils - extractRepoSlug', () => { | ||
describe('Utils - getSlugFromGitURL', () => { | ||
test('should fallback when the data is missing or invalid', () => { | ||
expect(extractRepoSlug(undefined)).toEqual(''); | ||
expect(extractRepoSlug('')).toEqual(''); | ||
expect(extractRepoSlug('invalid-url')).toEqual(''); | ||
expect(getSlugFromGitURL(undefined)).toEqual(undefined); | ||
expect(getSlugFromGitURL('')).toEqual(undefined); | ||
expect(getSlugFromGitURL('invalid-url')).toEqual(undefined); | ||
}); | ||
|
||
test('should extract slug from ssh URLs', () => { | ||
expect(extractRepoSlug('git@github.com:relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
expect(getSlugFromGitURL('git@github.com:relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
expect(getSlugFromGitURL('user@host.com:9418/relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
expect(getSlugFromGitURL('user@192.169.0.1:9418/relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
}); | ||
|
||
test('should extract slug from http(s) URLs', () => { | ||
expect(extractRepoSlug('https://github.com/relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
expect(getSlugFromGitURL('https://github.com/relative-ci/agent.git')).toEqual('relative-ci/agent'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters