fix(installer): preserve encoded ssh auth

This commit is contained in:
Loic Duong 2026-06-19 10:27:58 +07:00
parent 16ff771941
commit c5f7de38e2
2 changed files with 13 additions and 2 deletions

View File

@ -227,6 +227,16 @@ console.log(`\n${colors.cyan}Simple owner/repo URLs (regression check)${colors.r
assert(result.cacheKey === 'host:2222/path/repo', 'SSH protocol query/hash cacheKey ignores query and hash', `Got: ${result.cacheKey}`); assert(result.cacheKey === 'host:2222/path/repo', 'SSH protocol query/hash cacheKey ignores query and hash', `Got: ${result.cacheKey}`);
} }
{
const result = manager.parseSource('ssh://git%40corp@host:2222/path/repo.git?foo=bar#readme');
assert(result.isValid === true, 'SSH protocol URL with encoded username is valid');
assert(
result.cloneUrl === 'ssh://git%40corp@host:2222/path/repo.git',
'SSH protocol cloneUrl preserves encoded username',
`Got: ${result.cloneUrl}`,
);
}
{ {
const result = manager.parseSource('ssh://git@host/owner/repo.git'); const result = manager.parseSource('ssh://git@host/owner/repo.git');
assert(result.isValid === true, 'SSH protocol URL without custom port remains valid'); assert(result.isValid === true, 'SSH protocol URL without custom port remains valid');

View File

@ -171,8 +171,9 @@ class CustomModuleManager {
const repoSeg = segments.at(-1); const repoSeg = segments.at(-1);
const ownerSeg = segments.at(-2); const ownerSeg = segments.at(-2);
const displayName = ownerSeg ? `${ownerSeg}/${repoSeg}` : repoSeg; const displayName = ownerSeg ? `${ownerSeg}/${repoSeg}` : repoSeg;
const auth = url.username ? `${url.username}${url.password ? `:${url.password}` : ''}@` : ''; url.search = '';
const cloneUrl = `${url.protocol}//${auth}${url.host}/${repoPath}`; url.hash = '';
const cloneUrl = url.toString();
return { return {
type: 'url', type: 'url',