Skip to content

Commit

Permalink
Merge pull request #114 from Financial-Times/support-dot-in-repo-name
Browse files Browse the repository at this point in the history
Support a dot in repo names.
  • Loading branch information
jenniferemshepherd authored Jan 20, 2020
2 parents 1023ae3 + 8cf1fed commit e25fc5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions lib/github-helpers.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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`.
*
* @type {Array<string>}
*/
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',
'[email protected]: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',
'[email protected]:github-organization/github-repo.name.git'
];

/**
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/github-helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e25fc5e

Please sign in to comment.