( host: string, fullPath: string, gitlabInstanceUrl?: string )
| 116 | } |
| 117 | |
| 118 | function coordinatesFromHostAndPath( |
| 119 | host: string, |
| 120 | fullPath: string, |
| 121 | gitlabInstanceUrl?: string |
| 122 | ): RepoCoordinates | null { |
| 123 | if (host === 'github.com') { |
| 124 | // GitHub clone URLs always have exactly two segments (owner/repo). |
| 125 | const parts = fullPath.split('/'); |
| 126 | if (parts.length >= 2) { |
| 127 | return { platform: 'github', owner: parts[0], repo: parts[1] }; |
| 128 | } |
| 129 | return null; |
| 130 | } |
| 131 | |
| 132 | if (isGitLabHost(host, gitlabInstanceUrl)) { |
| 133 | // GitLab supports subgroups; owner is everything except the last segment. |
| 134 | const lastSlash = fullPath.lastIndexOf('/'); |
| 135 | if (lastSlash > 0) { |
| 136 | return { |
| 137 | platform: 'gitlab', |
| 138 | owner: fullPath.slice(0, lastSlash), |
| 139 | repo: fullPath.slice(lastSlash + 1), |
| 140 | }; |
| 141 | } |
| 142 | return null; |
| 143 | } |
| 144 | |
| 145 | return null; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Compose a `${owner}/${repo}` string suitable for repo-binding lookups. |
no test coverage detected