Skip to content

Commit

Permalink
Add more Github Enterprise URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
chadhietala authored and Gerrit0 committed Jul 17, 2022
1 parent dd15e08 commit 9e23a1d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib/converter/utils/repository.ts
Expand Up @@ -71,7 +71,7 @@ export class Repository {

for (let i = 0, c = repoLinks.length; i < c; i++) {
let match =
/(github(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
/(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
repoLinks[i]
);

Expand All @@ -82,6 +82,16 @@ export class Repository {
);
}

// Github Enterprise
if (!match) {
match = /(\w+\.ghe.com)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
}

// Github Enterprise
if (!match) {
match = /(\w+\.github.us)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
}

if (!match) {
match = /(bitbucket.org)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
}
Expand Down
26 changes: 26 additions & 0 deletions src/test/Repository.test.ts
Expand Up @@ -46,6 +46,32 @@ describe("Repository", function () {
equal(repository.type, RepositoryType.GitHub);
});

it("handles a ghe.com URL", function () {
const mockRemotes = [
"ssh://org@bigcompany.ghe.com/joebloggs/foobar.git",
];

const repository = new Repository("", "", mockRemotes);

equal(repository.hostname, "bigcompany.ghe.com");
equal(repository.user, "joebloggs");
equal(repository.project, "foobar");
equal(repository.type, RepositoryType.GitHub);
});

it("handles a github.us URL", function () {
const mockRemotes = [
"ssh://org@bigcompany.github.us/joebloggs/foobar.git",
];

const repository = new Repository("", "", mockRemotes);

equal(repository.hostname, "bigcompany.github.us");
equal(repository.user, "joebloggs");
equal(repository.project, "foobar");
equal(repository.type, RepositoryType.GitHub);
});

it("handles a Bitbucket HTTPS URL", function () {
const mockRemotes = [
"https://joebloggs@bitbucket.org/joebloggs/foobar.git",
Expand Down

0 comments on commit 9e23a1d

Please sign in to comment.