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 dot in usernames #786

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public class GitHubSCMSource extends AbstractGitSCMSource {

public static final String VALID_GITHUB_REPO_NAME = "^[0-9A-Za-z._-]+$";
public static final String VALID_GITHUB_USER_NAME =
"^(?=[A-Za-z0-9-_]{1,39}$)([A-Za-z0-9]((?:[A-Za-z0-9]+|-(?=[A-Za-z0-9]+))*)(_(?:[A-Za-z0-9]+))?)";
"^(?=[A-Za-z0-9-_.]{1,39}$)([A-Za-z0-9]((?:[A-Za-z0-9]+|[-.](?=[A-Za-z0-9]+))*)(_(?:[A-Za-z0-9]+))?)";
public static final String VALID_GIT_SHA1 = "^[a-fA-F0-9]{40}$";
public static final String GITHUB_URL = GitHubServerConfig.GITHUB_URL;
public static final String GITHUB_COM = "github.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ public void testUserNamesWithAndWithoutUnderscores() {
assertTrue("a".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertTrue("0".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertTrue("a-b-c-d-e-f-g".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertTrue("a.b".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertTrue("a.b.c".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));

// Valid names should contain alphanumeric characters or single hyphens, and cannot begin or end
// with a hyphen, and have a 39 char limit
Expand All @@ -960,5 +962,8 @@ public void testUserNamesWithAndWithoutUnderscores() {
assertFalse("user123-_org456".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertFalse("user123_org456-code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertFalse("user123_org456_code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertFalse(".user123_org456_code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertFalse("user123_org456_code789.".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
assertFalse("a..b".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME));
}
}