OXYGENHUB

Coverage / src/provider.ts 58.3%

14 of 24 lines run, 2 of 2 functions, 3 of 4 branches · run #22 on main · run missed

10×
// The remote provider registered with the Oxygen extension: a hub is any
20×
// base URL we know (signed in, or configured), and a remote URL is a
30×
// repository on one of them.
41×
50×
import { hubUrl, parseRepoUrl } from "./hub";
61×
7
export interface KnownHubs {
8
  bases(): string[];
9
}
101×
110×
export function makeProvider(hubs: KnownHubs) {
120×
  return {
130×
    id: "oxygenhub",
140×
    label: "OxygenHub",
152×
    matches(remoteUrl: string): boolean {
162×
      const p = parseRepoUrl(remoteUrl);
172×
      return !!p && hubs.bases().some((b) => b.replace(/\/$/, "") === p.base);
182×
    },
191×
    urlFor(remoteUrl: string, target: { kind: string; [k: string]: unknown }): string | undefined {
201×
      const p = parseRepoUrl(remoteUrl);
211×
      return p ? hubUrl(p.base, p.owner, p.name, target) : undefined;
221×
    },
230×
  };
240×
}