(repository: unknown)
| 267 | |
| 268 | /** Parse an "owner/repo" slug from a package.json `repository` field (string or object form). */ |
| 269 | export function parseRepoSlug(repository: unknown): string | undefined { |
| 270 | const url = |
| 271 | typeof repository === 'string' |
| 272 | ? repository |
| 273 | : repository && typeof repository === 'object' && 'url' in repository |
| 274 | ? String((repository as { url?: unknown }).url ?? '') |
| 275 | : ''; |
| 276 | if (!url) return undefined; |
| 277 | // Handles git+https://github.com/owner/repo.git, git@github.com:owner/repo.git, https://github.com/owner/repo |
| 278 | const match = url.match(/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?\/?(?:[#?].*)?$/); |
| 279 | return match ? `${match[1]}/${match[2]}` : undefined; |
| 280 | } |
| 281 | |
| 282 | export interface BuildPublishUrlOptions { |
| 283 | /** Configured registry for the package (bumpy config or publishConfig). */ |
no outgoing calls
no test coverage detected
searching dependent graphs…