mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 18:30:39 +09:00
Merge pull request #2449 from statxc/feat/github-enterprise-url-support
feat: GitHub enterprise url support
This commit is contained in:
commit
2c1883fc77
8 changed files with 121 additions and 68 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue