OXYGENHUB
◆ v0.13.0 oxygenhub-vscode / src / provider.ts
773 B · last changed Write the forge's name as OxygenHub in everything people read 1 month ago source blame history raw
f0b06dea Andy McCall 1
// The remote provider registered with the Oxygen extension: a hub is any
2
// base URL we know (signed in, or configured), and a remote URL is a
3
// repository on one of them.
4
5
import { hubUrl, parseRepoUrl } from "./hub";
6
7
export interface KnownHubs {
8
  bases(): string[];
9
}
10
11
export function makeProvider(hubs: KnownHubs) {
12
  return {
13
    id: "oxygenhub",
092b8bf9 Andy McCall ↶ 14
    label: "OxygenHub",
f0b06dea Andy McCall 15
    matches(remoteUrl: string): boolean {
16
      const p = parseRepoUrl(remoteUrl);
17
      return !!p && hubs.bases().some((b) => b.replace(/\/$/, "") === p.base);
18
    },
19
    urlFor(remoteUrl: string, target: { kind: string; [k: string]: unknown }): string | undefined {
20
      const p = parseRepoUrl(remoteUrl);
21
      return p ? hubUrl(p.base, p.owner, p.name, target) : undefined;
22
    },
23
  };
24
}