Coverage / src/provider.ts 58.3%
14 of 24 lines run, 2 of 2 functions, 3 of 4 branches · run #24 on main · run missed
| 1 | 0× | // The remote provider registered with the Oxygen extension: a hub is any |
| 2 | 0× | // base URL we know (signed in, or configured), and a remote URL is a |
| 3 | 0× | // repository on one of them. |
| 4 | 1× | |
| 5 | 0× | import { hubUrl, parseRepoUrl } from "./hub"; |
| 6 | 1× | |
| 7 | export interface KnownHubs { | |
| 8 | bases(): string[]; | |
| 9 | } | |
| 10 | 1× | |
| 11 | 0× | export function makeProvider(hubs: KnownHubs) { |
| 12 | 0× | return { |
| 13 | 0× | id: "oxygenhub", |
| 14 | 0× | label: "OxygenHub", |
| 15 | 2× | matches(remoteUrl: string): boolean { |
| 16 | 2× | const p = parseRepoUrl(remoteUrl); |
| 17 | 2× | return !!p && hubs.bases().some((b) => b.replace(/\/$/, "") === p.base); |
| 18 | 2× | }, |
| 19 | 1× | urlFor(remoteUrl: string, target: { kind: string; [k: string]: unknown }): string | undefined { |
| 20 | 1× | const p = parseRepoUrl(remoteUrl); |
| 21 | 1× | return p ? hubUrl(p.base, p.owner, p.name, target) : undefined; |
| 22 | 1× | }, |
| 23 | 0× | }; |
| 24 | 0× | } |