From 056512bfc3b63ac1895fc14ab228ec5df800469c Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 7 Mar 2023 19:38:43 -0500 Subject: [PATCH] Fixes #2553 allows remote formats we can parse --- src/commands/quickCommand.steps.ts | 3 ++- src/git/parsers/remoteParser.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 [