Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/regex.rb2
-rw-r--r--spec/lib/gitlab/regex_spec.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index 153613760fe..4b8038843b0 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -72,7 +72,7 @@ module Gitlab
end
def default_regex
- /\A[.?]?[a-zA-Z0-9_][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
+ /\A[a-zA-Z0-9_.][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
end
end
end
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
new file mode 100644
index 00000000000..a3aae7771bd
--- /dev/null
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe Gitlab::Regex do
+ describe 'path regex' do
+ it { 'gitlab-ce'.should match(Gitlab::Regex.path_regex) }
+ it { 'gitlab_git'.should match(Gitlab::Regex.path_regex) }
+ it { '_underscore.js'.should match(Gitlab::Regex.path_regex) }
+ it { '100px.com'.should match(Gitlab::Regex.path_regex) }
+ it { '?gitlab'.should_not match(Gitlab::Regex.path_regex) }
+ it { 'git lab'.should_not match(Gitlab::Regex.path_regex) }
+ it { 'gitlab.git'.should_not match(Gitlab::Regex.path_regex) }
+ end
+
+ describe 'project name regex' do
+ it { 'gitlab-ce'.should match(Gitlab::Regex.project_name_regex) }
+ it { 'GitLab CE'.should match(Gitlab::Regex.project_name_regex) }
+ it { '100 lines'.should match(Gitlab::Regex.project_name_regex) }
+ it { 'gitlab.git'.should match(Gitlab::Regex.project_name_regex) }
+ it { '?gitlab'.should_not match(Gitlab::Regex.project_name_regex) }
+ end
+end