Skip to content

Commit dbfb68d

Browse files
authored
Enhance repository URL handling in useRepositoryUrl
Updated URL construction to strip trailing .git and ensure proper formatting.
1 parent 5d8fcf5 commit dbfb68d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/composables/useRepositoryUrl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { joinURL } from 'ufo'
1+
import { joinURL, withoutTrailingSlash } from 'ufo'
22

33
type RequestedVersion = SlimPackument['requestedVersion'] | null
44

@@ -21,9 +21,11 @@ export function useRepositoryUrl(
2121
return null
2222
}
2323

24-
// append `repository.directory` for monorepo packages
24+
// Fix: Strip trailing .git (and any leftovers) before constructing the directory link
25+
url = url.replace(/\.git\/?$/, '')
26+
2527
if (repo.directory) {
26-
url = joinURL(`${url}/tree/HEAD`, repo.directory)
28+
url = joinURL(`${withoutTrailingSlash(url)}/tree/HEAD`, repo.directory)
2729
}
2830

2931
return url

0 commit comments

Comments
 (0)