refactor: rename URL validators to looksLikeRepoUrl

This commit is contained in:
statxc 2026-04-01 23:21:22 +00:00
parent 6a7830b07e
commit 9d89d74d70
5 changed files with 16 additions and 16 deletions

View file

@ -765,7 +765,7 @@ export function isHttpUrl(input: string): boolean {
return /^https?:\/\//i.test(input.trim());
}
export function isGithubUrl(input: string): boolean {
export function looksLikeRepoUrl(input: string): boolean {
try {
const url = new URL(input.trim());
if (url.protocol !== "https:") return false;
@ -843,7 +843,7 @@ export function normalizeGithubImportSource(input: string, refOverride?: string)
});
}
if (!isGithubUrl(trimmed)) {
if (!looksLikeRepoUrl(trimmed)) {
throw new Error("GitHub source must be a GitHub or GitHub Enterprise URL, or owner/repo[/path] shorthand.");
}
if (!ref) {
@ -1218,10 +1218,10 @@ export function registerCompanyCommands(program: Command): void {
| { type: "github"; url: string };
const treatAsLocalPath = !isHttpUrl(from) && await pathExists(from);
const isGithubSource = isGithubUrl(from) || (isGithubShorthand(from) && !treatAsLocalPath);
const isGithubSource = looksLikeRepoUrl(from) || (isGithubShorthand(from) && !treatAsLocalPath);
if (isHttpUrl(from) || isGithubSource) {
if (!isGithubUrl(from) && !isGithubShorthand(from)) {
if (!looksLikeRepoUrl(from) && !isGithubShorthand(from)) {
throw new Error(
"Only GitHub URLs and local paths are supported for import. " +
"Generic HTTP URLs are not supported. Use a GitHub or GitHub Enterprise URL (https://github.com/... or https://ghe.example.com/...) or a local directory path.",