Allow usage of www.github.com

This commit is contained in:
Nora
2023-02-01 11:34:49 +00:00
parent 72412c92c8
commit 4c54778515
2 changed files with 7 additions and 1 deletions

View File

@@ -51,7 +51,11 @@ function getNwoOrOwnerFromGitHubUrl(
): string | undefined {
try {
let paths: string[];
if (githubUrl.split("/")[0] === "github.com") {
const urlElements = githubUrl.split("/");
if (
urlElements[0] === "github.com" ||
urlElements[0] === "www.github.com"
) {
paths = githubUrl.split("/").slice(1);
} else {
const uri = new URL(githubUrl);

View File

@@ -34,6 +34,7 @@ describe("github url identifier helper", () => {
it("should handle valid urls", () => {
expect(getNwoFromGitHubUrl("github.com/foo/bar")).toBe("foo/bar");
expect(getNwoFromGitHubUrl("www.github.com/foo/bar")).toBe("foo/bar");
expect(getNwoFromGitHubUrl("https://github.com/foo/bar")).toBe("foo/bar");
expect(getNwoFromGitHubUrl("http://github.com/foo/bar")).toBe("foo/bar");
expect(getNwoFromGitHubUrl("https://www.github.com/foo/bar")).toBe(
@@ -66,6 +67,7 @@ describe("github url identifier helper", () => {
).toBe("foo");
expect(getOwnerFromGitHubUrl("https://www.github.com/foo")).toBe("foo");
expect(getOwnerFromGitHubUrl("github.com/foo")).toBe("foo");
expect(getOwnerFromGitHubUrl("www.github.com/foo")).toBe("foo");
});
});
});