diff --git a/packages/cli/src/config/extensions/github.ts b/packages/cli/src/config/extensions/github.ts index 187e790f2a3..4d0c4409a9a 100644 --- a/packages/cli/src/config/extensions/github.ts +++ b/packages/cli/src/config/extensions/github.ts @@ -89,7 +89,16 @@ export function tryParseGithubUrl(source: string): GithubRepoInfo | null { source = source.replace('git@github.com:', ''); } // Default to a github repo path, so `source` can be just an org/repo - const parsedUrl = URL.parse(source, 'https://github.com'); + let parsedUrl: URL; + try { + // Use the standard URL constructor for backward compatibility. + parsedUrl = new URL(source, 'https://github.com'); + } catch (e) { + // Throw a TypeError to maintain a consistent error contract for invalid URLs. + // This avoids a breaking change for consumers who might expect a TypeError. + throw new TypeError(`Invalid repo URL: ${source}`, { cause: e }); + } + if (!parsedUrl) { throw new Error(`Invalid repo URL: ${source}`); }