diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index fc1ae1e..cb4ab04 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -37,6 +37,7 @@ import type { GitStatus } from '../git/models/status'; import type { GitTag, TagSortOptions } from '../git/models/tag'; import { sortTags } from '../git/models/tag'; import type { GitWorktree } from '../git/models/worktree'; +import { remoteUrlRegex } from '../git/parsers/remoteParser'; import { CommitApplyFileChangesCommandQuickPickItem, CommitBrowseRepositoryFromHereCommandQuickPickItem, @@ -606,7 +607,7 @@ export async function* inputRemoteUrlStep< value = value.trim(); if (value.length === 0) return [false, 'Please enter a valid remote URL']; - const valid = /^(https?|git|ssh|rsync):\/\//.test(value); + const valid = remoteUrlRegex.test(value); return [valid, valid ? undefined : `'${value}' isn't a valid remote URL`]; }, }); diff --git a/src/git/parsers/remoteParser.ts b/src/git/parsers/remoteParser.ts index c700784..bace1de 100644 --- a/src/git/parsers/remoteParser.ts +++ b/src/git/parsers/remoteParser.ts @@ -109,11 +109,11 @@ user:password@host.xz:project.git user:password@host.xz:/path/to/repo.git user:password@host.xz:/path/to/repo.git/ */ -const urlRegex = +export const remoteUrlRegex = /^(?:(git:\/\/)(.*?)\/|(https?:\/\/)(?:.*?@)?(.*?)\/|git@(.*):|(ssh:\/\/)(?:.*@)?(.*?)(?::.*?)?(?:\/|(?=~))|(?:.*?@)(.*?):)(.*)$/; export function parseGitRemoteUrl(url: string): [scheme: string, domain: string, path: string] { - const match = urlRegex.exec(url); + const match = remoteUrlRegex.exec(url); if (match == null) return [emptyStr, emptyStr, url]; return [