diff --git a/lib/github-helpers.js b/lib/github-helpers.js index f833c39..cd9f244 100644 --- a/lib/github-helpers.js +++ b/lib/github-helpers.js @@ -1,4 +1,4 @@ -const GITHUB_REPO_REGEX = /^(?:\S*github\.com(?:\/|:))?([\w-]+)\/([\w-]+)/; +const GITHUB_REPO_REGEX = /^(?:\S*github\.com(?:\/|:))?([\w-]+)\/([\w-\.]+)/; /** * Array of repo string patterns supported by `extractOwnerAndRepo`. @@ -6,14 +6,14 @@ const GITHUB_REPO_REGEX = /^(?:\S*github\.com(?:\/|:))?([\w-]+)\/([\w-]+)/; * @type {Array} */ const SUPPORTED_REPO_STRING_PATTERNS = [ - 'github-organization/github-repo-name', - 'github.com/github-organization/github-repo-name', - 'subdomain.github.com/github-organization/github-repo-name', - 'https://github.com/github-organization/github-repo-name', - 'https://github.com/github-organization/github-repo-name/blob/master', - 'https://github.com/github-organization/github-repo-name.git', - 'git+https://github.com/github-organization/github-repo-name.git', - 'git@github.com:github-organization/github-repo-name.git' + 'github-organization/github-repo.name', + 'github.com/github-organization/github-repo.name', + 'subdomain.github.com/github-organization/github-repo.name', + 'https://github.com/github-organization/github-repo.name', + 'https://github.com/github-organization/github-repo.name/blob/master', + 'https://github.com/github-organization/github-repo.name.git', + 'git+https://github.com/github-organization/github-repo.name.git', + 'git@github.com:github-organization/github-repo.name.git' ]; /** @@ -24,6 +24,9 @@ const SUPPORTED_REPO_STRING_PATTERNS = [ * @returns {object} - Properties: owner, repo */ function extractOwnerAndRepo(githubRepoString) { + // Remove trailing .git extension + githubRepoString = githubRepoString.replace(/.git$/, ''); + // Match owner and repo const matches = GITHUB_REPO_REGEX.exec(githubRepoString); if (matches === null) { diff --git a/test/lib/github-helpers.test.js b/test/lib/github-helpers.test.js index 14bc92a..e2ac968 100644 --- a/test/lib/github-helpers.test.js +++ b/test/lib/github-helpers.test.js @@ -4,7 +4,7 @@ const { } = require('../../lib/github-helpers'); const expectedOwner = 'github-organization'; -const expectedRepo = 'github-repo-name'; +const expectedRepo = 'github-repo.name'; const supportedRepoStrings = SUPPORTED_REPO_STRING_PATTERNS;