From d7dc4dd507e91926c6f33a1be6180c35079eaa3f Mon Sep 17 00:00:00 2001 From: dcode Date: Sun, 25 Oct 2020 10:31:59 +0100 Subject: [PATCH] fix: Be more lenient when validating repository urls --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index abfcada..ef89eea 100644 --- a/index.js +++ b/index.js @@ -139,9 +139,11 @@ export function getCommitsSince(sinceCommit = null) { /** Gets the current repository. */ export function getRepo() { const url = exec("git", ["config", "--get", "remote.origin.url"]); - const match = /(\w+)\/(\w+)(?:\.git)?$/.exec(url); + const match = /\/(\w(?:[-_.]?\w)*)\/(\w(?:[-_.]?\w)*)$/.exec(url); if (!match) throw Error("invalid repository url: " + url); - return match[1] + "/" + match[2]; + const user = match[1]; + const repo = match[2].replace(/\.git$/, ""); + return `${user}/${repo}`; } /** Gets the GitHub token to use. */