Skip to content

Commit

Permalink
fix: Be more lenient when validating repository urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Oct 25, 2020
1 parent f435ec0 commit d7dc4dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit d7dc4dd

Please sign in to comment.