diff --git a/test/test-parse-source-urls.js b/test/test-parse-source-urls.js index 98dec45aa..c453fd136 100644 --- a/test/test-parse-source-urls.js +++ b/test/test-parse-source-urls.js @@ -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}`); } +{ + 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'); assert(result.isValid === true, 'SSH protocol URL without custom port remains valid'); diff --git a/tools/installer/modules/custom-module-manager.js b/tools/installer/modules/custom-module-manager.js index 6a4b68be6..f0488ca49 100644 --- a/tools/installer/modules/custom-module-manager.js +++ b/tools/installer/modules/custom-module-manager.js @@ -171,8 +171,9 @@ class CustomModuleManager { const repoSeg = segments.at(-1); const ownerSeg = segments.at(-2); const displayName = ownerSeg ? `${ownerSeg}/${repoSeg}` : repoSeg; - const auth = url.username ? `${url.username}${url.password ? `:${url.password}` : ''}@` : ''; - const cloneUrl = `${url.protocol}//${auth}${url.host}/${repoPath}`; + url.search = ''; + url.hash = ''; + const cloneUrl = url.toString(); return { type: 'url',