Merge pull request #2449 from statxc/feat/github-enterprise-url-support

feat: GitHub enterprise url support
This commit is contained in:
Dotta 2026-04-02 06:07:44 -05:00 committed by GitHub
commit 2c1883fc77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 121 additions and 68 deletions

View file

@ -118,11 +118,10 @@ export function NewProjectDialog() {
const isAbsolutePath = (value: string) => value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value);
const isGitHubRepoUrl = (value: string) => {
const looksLikeRepoUrl = (value: string) => {
try {
const parsed = new URL(value);
const host = parsed.hostname.toLowerCase();
if (host !== "github.com" && host !== "www.github.com") return false;
if (parsed.protocol !== "https:") return false;
const segments = parsed.pathname.split("/").filter(Boolean);
return segments.length >= 2;
} catch {
@ -156,8 +155,8 @@ export function NewProjectDialog() {
setWorkspaceError("Local folder must be a full absolute path.");
return;
}
if (repoUrl && !isGitHubRepoUrl(repoUrl)) {
setWorkspaceError("Repo must use a valid GitHub repo URL.");
if (repoUrl && !looksLikeRepoUrl(repoUrl)) {
setWorkspaceError("Repo must use a valid GitHub or GitHub Enterprise repo URL.");
return;
}

View file

@ -343,11 +343,10 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
const isAbsolutePath = (value: string) => value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value);
const isGitHubRepoUrl = (value: string) => {
const looksLikeRepoUrl = (value: string) => {
try {
const parsed = new URL(value);
const host = parsed.hostname.toLowerCase();
if (host !== "github.com" && host !== "www.github.com") return false;
if (parsed.protocol !== "https:") return false;
const segments = parsed.pathname.split("/").filter(Boolean);
return segments.length >= 2;
} catch {
@ -432,8 +431,8 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
persistCodebase({ repoUrl: null });
return;
}
if (!isGitHubRepoUrl(repoUrl)) {
setWorkspaceError("Repo must use a valid GitHub repo URL.");
if (!looksLikeRepoUrl(repoUrl)) {
setWorkspaceError("Repo must use a valid GitHub or GitHub Enterprise repo URL.");
return;
}
setWorkspaceError(null);