( provider: RepoProvider | undefined, owner: string | undefined, repo: string | undefined, gitlabSplat?: string )
| 81 | |
| 82 | /** Build a RepoRef from route parameters. */ |
| 83 | export function repoRefFromRoute( |
| 84 | provider: RepoProvider | undefined, |
| 85 | owner: string | undefined, |
| 86 | repo: string | undefined, |
| 87 | gitlabSplat?: string |
| 88 | ): RepoRef | null { |
| 89 | if (provider === "gitlab") { |
| 90 | const fullPath = cleanRepoPathSegment(gitlabSplat || ""); |
| 91 | if (!fullPath) return null; |
| 92 | const parts = fullPath.split("/").filter(Boolean); |
| 93 | if (parts.length < 2) return null; |
| 94 | const repoName = parts[parts.length - 1]; |
| 95 | const ownerPath = parts.slice(0, -1).join("/"); |
| 96 | return { |
| 97 | provider: "gitlab", |
| 98 | owner: ownerPath, |
| 99 | repo: repoName, |
| 100 | fullPath, |
| 101 | host: GITLAB_HOST, |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | if (!owner || !repo) return null; |
| 106 | return { |
| 107 | provider: provider === "github" ? "github" : "github", |
| 108 | owner, |
| 109 | repo, |
| 110 | fullPath: `${owner}/${repo}`, |
| 111 | host: GITHUB_HOST, |
| 112 | }; |
| 113 | } |
| 114 | |
| 115 | /** Guess provider from partial user input (URL or shorthand). Defaults to GitHub. */ |
| 116 | export function detectProviderFromInput(input: string): RepoProvider { |
no test coverage detected