Skip to content

Commit 08bb6fe

Browse files
committed
Refactor SmartBarFeatures to improve Git repository URL handling by splitting input for better folder name extraction
1 parent 40ad0d7 commit 08bb6fe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/client-with-vite/src/lib/smartbar/SmartBarFeatures.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ export const SmartBarFeatures = [
4545
},
4646
icon: GitBranch,
4747
placeholder: 'Git repository URL to clone',
48-
match: (input: string) => GIT_REPO_REGEX.test(input.trim()) || GIT_CLONE_PREFIX_REGEX.test(input.trim()),
48+
match: (input: string) =>
49+
GIT_REPO_REGEX.test(input.trim().split(' ')[0]) || //
50+
GIT_CLONE_PREFIX_REGEX.test(input.trim()),
4951
action: async (input: string) => {
50-
const repoUrl = input.trim().replace(GIT_CLONE_PREFIX_REGEX, '');
51-
const repoName = repoUrl.split('/').pop()?.replace('.git', '') || 'cloned-repo';
52+
const [repoUrl, folder] = input.trim().replace(GIT_CLONE_PREFIX_REGEX, '').split(' ');
53+
const repoName = folder || repoUrl.split('/').pop()?.replace('.git', '') || 'cloned-repo';
5254
const cloneCommand = `
5355
REPO_NAME="${repoName}"
5456
COUNTER=0

0 commit comments

Comments
 (0)