Skip to content

Commit 01e6307

Browse files
authored
fix: tests (#526)
1 parent 397fe4a commit 01e6307

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

packages/app/e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ beforeAll(async () => {
7575
shell: true,
7676
},
7777
);
78-
}, 70_000);
78+
}, 180_000);
7979

8080
afterAll(async () => {
8181
await server.ensureClose();
@@ -156,7 +156,7 @@ describe.sequential.each([
156156
expect(process.stderr).toContain(
157157
"private-playground/ because the package is private",
158158
);
159-
}, 20_000);
159+
}, 60_000);
160160

161161
it(`serves and installs playground-a for ${mode}`, async () => {
162162
const [owner, repo] = payload.repository.full_name.split("/");

packages/utils/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ describe("utils", () => {
4747
utils.extractOwnerAndRepo("git+http://github.com/org/repo.git"),
4848
).toEqual(["org", "repo"]);
4949
});
50+
51+
it("returns org and repo for GitHub shorthand", () => {
52+
expect(utils.extractOwnerAndRepo("org/repo")).toEqual(["org", "repo"]);
53+
});
54+
55+
it("returns org and repo for github: shorthand", () => {
56+
expect(utils.extractOwnerAndRepo("github:org/repo")).toEqual([
57+
"org",
58+
"repo",
59+
]);
60+
});
61+
62+
it("returns org and repo for URLs without .git suffix", () => {
63+
expect(utils.extractOwnerAndRepo("https://github.com/org/repo")).toEqual([
64+
"org",
65+
"repo",
66+
]);
67+
});
5068
});
5169

5270
describe("extractRepository", () => {

packages/utils/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import type { PackageManifest } from "query-registry";
22

33
const githubUrlRegex =
4-
/^(?:git\+)?https?:\/\/github\.com\/([^/]+)\/([^/]+)\.git$/;
4+
/^(?:git\+)?https?:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/;
5+
const githubShorthandRegex = /^(?:github:)?([^/]+)\/([^/]+)$/;
56

67
export function extractOwnerAndRepo(
78
repositoryUrl: string,
89
): [string, string] | null {
9-
const match = repositoryUrl.match(githubUrlRegex);
10+
const match =
11+
repositoryUrl.match(githubUrlRegex) ??
12+
repositoryUrl.match(githubShorthandRegex);
1013

1114
if (match) {
12-
return [match[1], match[2]];
15+
let repo = match[2];
16+
if (repo.endsWith(".git")) {
17+
repo = repo.slice(0, -4);
18+
} else if (repo.includes(".git")) {
19+
return null;
20+
}
21+
22+
return [match[1], repo];
1323
}
1424

1525
return null;

0 commit comments

Comments
 (0)