summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/regex.rb4
-rw-r--r--spec/lib/gitlab/regex_spec.rb15
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index e4d2a992470..4d622a60a40 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -39,11 +39,11 @@ module Gitlab
end
def environment_name_regex
- @environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -]+\z/.freeze
+ @environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -%']+\z/.freeze
end
def environment_name_regex_message
- "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces"
+ "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', '%', ''' and spaces"
end
def kubernetes_namespace_regex
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index 0bee892fe0c..145606500fb 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -20,6 +20,21 @@ describe Gitlab::Regex, lib: true do
it { is_expected.to match('foo@bar') }
end
+
+ describe '.environment_slug_regex' do
+ subject { described_class.environment_name_regex }
+
+ it { is_expected.to match('foo') }
+ it { is_expected.to match('foo-1') }
+ it { is_expected.to match('FOO') }
+ it { is_expected.to match('foo/1') }
+ it { is_expected.to match('foo.1') }
+ it { is_expected.to match('foo%1') }
+ it { is_expected.to match("foo'1") }
+ it { is_expected.not_to match('9&foo') }
+ it { is_expected.not_to match('foo-^') }
+ end
+
describe '.environment_slug_regex' do
subject { described_class.environment_slug_regex }