(
repository?: { type?: string; url?: string; directory?: string } | string,
)
| 321 | * Supports both full objects and shorthand strings. |
| 322 | */ |
| 323 | export function parseRepositoryInfo( |
| 324 | repository?: { type?: string; url?: string; directory?: string } | string, |
| 325 | ): RepositoryInfo | undefined { |
| 326 | if (!repository) return undefined |
| 327 | |
| 328 | let url: string | undefined |
| 329 | let directory: string | undefined |
| 330 | |
| 331 | if (typeof repository === 'string') { |
| 332 | url = repository |
| 333 | } else { |
| 334 | url = repository.url |
| 335 | directory = repository.directory |
| 336 | } |
| 337 | |
| 338 | if (!url) return undefined |
| 339 | |
| 340 | const ref = parseRepoUrl(url) |
| 341 | if (!ref) return undefined |
| 342 | |
| 343 | const provider = providers.find(p => p.id === ref.provider) |
| 344 | if (!provider) return undefined |
| 345 | |
| 346 | return { |
| 347 | ...ref, |
| 348 | rawBaseUrl: provider.getRawBaseUrl(ref), |
| 349 | blobBaseUrl: provider.getBlobBaseUrl(ref), |
| 350 | directory: directory ? withoutTrailingSlash(directory) : undefined, |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | export function getProviderConfig(providerId: ProviderId): ProviderConfig | undefined { |
| 355 | return providers.find(p => p.id === providerId) |
no test coverage detected