Skip to content

Commit 4c54778

Browse files
committed
Allow usage of www.github.com
1 parent 72412c9 commit 4c54778

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

extensions/ql-vscode/src/common/github-url-identifier-helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ function getNwoOrOwnerFromGitHubUrl(
5151
): string | undefined {
5252
try {
5353
let paths: string[];
54-
if (githubUrl.split("/")[0] === "github.com") {
54+
const urlElements = githubUrl.split("/");
55+
if (
56+
urlElements[0] === "github.com" ||
57+
urlElements[0] === "www.github.com"
58+
) {
5559
paths = githubUrl.split("/").slice(1);
5660
} else {
5761
const uri = new URL(githubUrl);

extensions/ql-vscode/test/unit-tests/common/github-url-identifier-helper.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("github url identifier helper", () => {
3434

3535
it("should handle valid urls", () => {
3636
expect(getNwoFromGitHubUrl("github.com/foo/bar")).toBe("foo/bar");
37+
expect(getNwoFromGitHubUrl("www.github.com/foo/bar")).toBe("foo/bar");
3738
expect(getNwoFromGitHubUrl("https://github.com/foo/bar")).toBe("foo/bar");
3839
expect(getNwoFromGitHubUrl("http://github.com/foo/bar")).toBe("foo/bar");
3940
expect(getNwoFromGitHubUrl("https://www.github.com/foo/bar")).toBe(
@@ -66,6 +67,7 @@ describe("github url identifier helper", () => {
6667
).toBe("foo");
6768
expect(getOwnerFromGitHubUrl("https://www.github.com/foo")).toBe("foo");
6869
expect(getOwnerFromGitHubUrl("github.com/foo")).toBe("foo");
70+
expect(getOwnerFromGitHubUrl("www.github.com/foo")).toBe("foo");
6971
});
7072
});
7173
});

0 commit comments

Comments
 (0)