Allow usage of github.com

This commit is contained in:
Nora
2023-02-01 11:32:57 +00:00
parent 9e54e5eced
commit 72412c92c8
2 changed files with 11 additions and 4 deletions

View File

@@ -50,11 +50,16 @@ function getNwoOrOwnerFromGitHubUrl(
kind: "owner" | "nwo",
): string | undefined {
try {
const uri = new URL(githubUrl);
if (uri.hostname !== "github.com" && uri.hostname !== "www.github.com") {
return;
let paths: string[];
if (githubUrl.split("/")[0] === "github.com") {
paths = githubUrl.split("/").slice(1);
} else {
const uri = new URL(githubUrl);
if (uri.hostname !== "github.com" && uri.hostname !== "www.github.com") {
return;
}
paths = uri.pathname.split("/").filter((segment: string) => segment);
}
const paths = uri.pathname.split("/").filter((segment: string) => segment);
const owner = `${paths[0]}`;
if (kind === "owner") {
return owner ? owner : undefined;