提交 1319a5ed 编写于 作者: T Tomas Vik

Merge branch '220-migrate-gitlab-service' into 'main'

refactor(gitlab_service): convert service to TypeScript

Closes #220

See merge request gitlab-org/gitlab-vscode-extension!122
......@@ -34,6 +34,14 @@ describe('git_remote_parser', () => {
'https://gitlab.com/fatihacet/gitlab-vscode-extension.git',
['gitlab.com', 'fatihacet', 'gitlab-vscode-extension'],
],
[
'git@gitlab.com:group/subgroup/gitlab-vscode-extension.git',
['gitlab.com', 'group/subgroup', 'gitlab-vscode-extension'],
],
[
'http://gitlab.com/group/subgroup/gitlab-vscode-extension.git',
['gitlab.com', 'group/subgroup', 'gitlab-vscode-extension'],
],
[
'https://gitlab.com/fatihacet/gitlab-vscode-extension',
['gitlab.com', 'fatihacet', 'gitlab-vscode-extension'],
......@@ -46,6 +54,11 @@ describe('git_remote_parser', () => {
'https://gitlab.company.com:8443/fatihacet/gitlab-vscode-extension.git',
['gitlab.company.com:8443', 'fatihacet', 'gitlab-vscode-extension'],
],
[
// trailing / can be present if user copied the repo URL from the browser navigation bar
'https://gitlab.company.com:8443/fatihacet/gitlab-vscode-extension/',
['gitlab.company.com:8443', 'fatihacet', 'gitlab-vscode-extension'],
],
])('should parse %s', (remote, parsed) => {
const [host, namespace, project] = parsed;
expect(parseGitRemote('https://gitlab.com', remote)).toEqual({
......
......@@ -27,7 +27,7 @@ export function parseGitRemote(instanceUrl: string, remote: string): GitRemote |
}
const pathRegExp = escapeForRegExp(getInstancePath(instanceUrl));
const match = pathname.match(`${pathRegExp}/:?(.+)/(.*?)(?:.git)?$`);
const match = pathname.match(`${pathRegExp}/:?(.+)/([^/]+?)(?:.git)?/?$`);
if (!match) {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册