Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a dot in repo names. #114

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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