From dbfb68d69561140ba7fbbba93f0ff3ecfd8e87bb Mon Sep 17 00:00:00 2001 From: Thirumalesh Chinna Date: Thu, 19 Mar 2026 12:39:13 +0530 Subject: [PATCH] Enhance repository URL handling in useRepositoryUrl Updated URL construction to strip trailing .git and ensure proper formatting. --- app/composables/useRepositoryUrl.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/composables/useRepositoryUrl.ts b/app/composables/useRepositoryUrl.ts index 0e65aa0ee6..ac53ee35ce 100644 --- a/app/composables/useRepositoryUrl.ts +++ b/app/composables/useRepositoryUrl.ts @@ -1,4 +1,4 @@ -import { joinURL } from 'ufo' +import { joinURL, withoutTrailingSlash } from 'ufo' type RequestedVersion = SlimPackument['requestedVersion'] | null @@ -21,9 +21,11 @@ export function useRepositoryUrl( return null } - // append `repository.directory` for monorepo packages + // Fix: Strip trailing .git (and any leftovers) before constructing the directory link + url = url.replace(/\.git\/?$/, '') + if (repo.directory) { - url = joinURL(`${url}/tree/HEAD`, repo.directory) + url = joinURL(`${withoutTrailingSlash(url)}/tree/HEAD`, repo.directory) } return url