Commit 23eb7efa authored by Mathieu Parent's avatar Mathieu Parent

Add Debian Component Regexp

parent fe471849
......@@ -80,7 +80,7 @@ module API
end
params do
requires :component, type: String, desc: 'The Debian Component'
requires :component, type: String, desc: 'The Debian Component', regexp: Gitlab::Regex.debian_component_regex
requires :architecture, type: String, desc: 'The Debian Architecture', regexp: Gitlab::Regex.debian_architecture_regex
end
......@@ -99,7 +99,7 @@ module API
end
params do
requires :component, type: String, desc: 'The Debian Component'
requires :component, type: String, desc: 'The Debian Component', regexp: Gitlab::Regex.debian_component_regex
requires :letter, type: String, desc: 'The Debian Classification (first-letter or lib-first-letter)'
requires :source_package, type: String, desc: 'The Debian Source Package Name', regexp: Gitlab::Regex.debian_package_name_regex
end
......
......@@ -90,6 +90,10 @@ module Gitlab
@debian_distribution_regex ||= %r{\A[a-z0-9][a-z0-9\.-]*\z}i.freeze
end
def debian_component_regex
@debian_component_regex ||= %r{#{debian_distribution_regex}}.freeze
end
def unbounded_semver_regex
# See the official regex: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
......
......@@ -535,6 +535,19 @@ RSpec.describe Gitlab::Regex do
it { is_expected.not_to match('hé') }
end
describe '.debian_component_regex' do
subject { described_class.debian_component_regex }
it { is_expected.to match('main') }
it { is_expected.to match('non-free') }
# Do not allow slash
it { is_expected.not_to match('non/free') }
# Do not allow Unicode
it { is_expected.not_to match('hé') }
end
describe '.semver_regex' do
subject { described_class.semver_regex }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment