Unified · Split
| @@ -67,6 +67,13 @@ const bestDetection = ( · 66 unmodified lines | ||
| 67 | 67 | ): IntegrationDetectionResult | undefined => |
| 68 | 68 | [...results].sort((a, b) => detectionRank[b.confidence] - detectionRank[a.confidence])[0]; |
| 69 | 69 | |
| 70 | +// Hosts where a two-segment path (owner/repo) is unambiguously a git remote. | |
| 71 | +const GIT_REPO_HOSTS = new Set(["github.com", "gitlab.com", "bitbucket.org", "codeberg.org"]); | |
| 72 | + | |
| 73 | +// Deliberately conservative: only claim URLs that are unambiguously git | |
| 74 | +// remotes (a `.git` suffix, or owner/repo on a known git host). Anything else | |
| 75 | +// falls through to the server-side detection so OpenAPI/MCP/GraphQL URLs keep | |
| 76 | +// their existing flows. | |
| 70 | 77 | const detectGitRepository = ( |
| 71 | 78 | raw: string, |
| 72 | 79 | ): { readonly endpoint: string; readonly slug: string } | null => { |
| @@ -76,6 +83,11 @@ const detectGitRepository = ( · 3 unmodified lines | ||
| 76 | 83 | if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null; |
| 77 | 84 | if (parsed.username || parsed.password) return null; |
| 78 | 85 | const segments = parsed.pathname.split("/").filter(Boolean); |
| 86 | + const knownGitHost = | |
| 87 | + GIT_REPO_HOSTS.has(parsed.hostname.toLowerCase()) && | |
| 88 | + segments.length === 2 && | |
| 89 | + parsed.search === ""; | |
| 90 | + if (!parsed.pathname.endsWith(".git") && !knownGitHost) return null; | |
| 79 | 91 | const name = segments.at(-1)?.replace(/\.git$/, "") ?? ""; |
| 80 | 92 | if (!name) return null; |
| 81 | 93 | parsed.hash = ""; |