diff --git a/changelogs/unreleased/dz-fix-500-group-git.yml b/changelogs/unreleased/dz-fix-500-group-git.yml new file mode 100644 index 0000000000000000000000000000000000000000..38e80ad8bde446d1b22f8b4bee85c1667254fd8f --- /dev/null +++ b/changelogs/unreleased/dz-fix-500-group-git.yml @@ -0,0 +1,4 @@ +--- +title: Fix 500 error when group name ends with git +merge_request: 7630 +author: diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 47ea8b7e82e6d104d9ed9d08c55c344551412abf..c12358ceef4cdf5e3301a559f58b1739139053a5 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -9,7 +9,7 @@ module Gitlab # `NAMESPACE_REGEX_STR`, with the negative lookbehind assertion removed. This means that the client-side validation # will pass for usernames ending in `.atom` and `.git`, but will be caught by the server-side validation. NAMESPACE_REGEX_STR_SIMPLE = '[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'.freeze - NAMESPACE_REGEX_STR = "(?:#{NAMESPACE_REGEX_STR_SIMPLE})(?<!\.git|\.atom)".freeze + NAMESPACE_REGEX_STR = '(?:' + NAMESPACE_REGEX_STR_SIMPLE + ')(?<!\.git|\.atom)'.freeze def namespace_regex @namespace_regex ||= /\A#{NAMESPACE_REGEX_STR}\z/.freeze diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 7aba4f080885c6c03db563167c0e85485fc97a60..f15c45cbaac8e0ea9b05ebd68ce4653af2cb4270 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -261,7 +261,7 @@ describe "Authentication", "routing" do end describe "Groups", "routing" do - let(:name) { 'complex.group-name' } + let(:name) { 'complex.group-namegit' } it "to #show" do expect(get("/groups/#{name}")).to route_to('groups#show', id: name)