Skip to content

Commit 4d69373

Browse files
committed
fix: stop truncating repo paths for non-supported hosts
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 9ac2223 commit 4d69373

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

services/apps/packages_worker/src/utils/canonicalizeRepoUrl.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@ export function canonicalizeRepoUrl(raw: string): CanonicalRepo | null {
6868
const segments = u.pathname.split('/').filter(Boolean)
6969
if (segments.length < 2) return null
7070

71-
let owner = segments[0]
72-
let name = segments[1].replace(/\.git$/, '')
73-
if (!owner || !name) return null
71+
const isKnownHost = hostname in HOST_ENUM
72+
let ownerPath = isKnownHost ? [segments[0]] : segments.slice(0, -1)
73+
let name = (isKnownHost ? segments[1] : segments[segments.length - 1]).replace(/\.git$/, '')
74+
if (!name || ownerPath.length === 0 || ownerPath.some((seg) => !seg)) return null
7475

7576
if (CASE_INSENSITIVE_HOSTS.has(hostname)) {
76-
owner = owner.toLowerCase()
77+
ownerPath = ownerPath.map((seg) => seg.toLowerCase())
7778
name = name.toLowerCase()
7879
}
7980

8081
return {
81-
url: `https://${hostname}/${owner}/${name}`,
82+
url: `https://${hostname}/${[...ownerPath, name].join('/')}`,
8283
host: HOST_ENUM[hostname] ?? 'other',
8384
}
8485
}

0 commit comments

Comments
 (0)