@@ -30,6 +30,20 @@ const emit = defineEmits<Emits>()
3030const repositoryUrl = ref (props .modelValue ?.repository_url || ' ' )
3131const validationError = ref <string | null >(null )
3232
33+ // Clean repository URL by removing query parameters and hash fragments
34+ // e.g., https://github.com/owner/repo?tab=readme-ov-file -> https://github.com/owner/repo
35+ const cleanRepositoryUrl = (url : string ): string => {
36+ if (! url || url .trim () === ' ' ) return ' '
37+ try {
38+ const parsed = new URL (url )
39+ // Return just the origin + pathname (no search params or hash)
40+ return ` ${parsed .origin }${parsed .pathname } ` .replace (/ \/ $ / , ' ' ) // Also remove trailing slash
41+ } catch {
42+ // If URL parsing fails, do basic string cleanup
43+ return url .split (' ?' )[0 ]?.split (' #' )[0 ]?.replace (/ \/ $ / , ' ' ) || url
44+ }
45+ }
46+
3347// Basic repository URL validation (supports any Git platform)
3448// Returns true if URL is empty (optional) or if it's a valid format
3549const isValidRepositoryUrl = computed (() => {
@@ -60,19 +74,22 @@ const validateUrl = () => {
6074
6175 validationError .value = null
6276
77+ // Clean the URL (remove query params and hash fragments)
78+ const cleanedUrl = cleanRepositoryUrl (repositoryUrl .value )
79+
6380 // Detect repository source from URL
6481 let source = ' github'
65- if (repositoryUrl . value .includes (' github.com' )) {
82+ if (cleanedUrl .includes (' github.com' )) {
6683 source = ' github'
67- } else if (repositoryUrl . value .includes (' gitlab.com' )) {
84+ } else if (cleanedUrl .includes (' gitlab.com' )) {
6885 source = ' gitlab'
69- } else if (repositoryUrl . value .includes (' bitbucket.org' )) {
86+ } else if (cleanedUrl .includes (' bitbucket.org' )) {
7087 source = ' bitbucket'
7188 }
7289
73- // Update parent component
90+ // Update parent component with cleaned URL
7491 emit (' update:modelValue' , {
75- repository_url: repositoryUrl . value ,
92+ repository_url: cleanedUrl ,
7693 repository_source: source ,
7794 git_branch: ' main' , // Default branch
7895 auto_populated: false
0 commit comments