diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 02fe82bf0..597b4a198 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -96,7 +96,12 @@ def self.get_from_name(name, registry = nil) def self.make_valid(name) return name if name =~ NAME_REGEXP - # First of all we strip extra characters from the beginning and end. + # One common case is LDAP and case sensitivity. With this in mind, try to + # downcase everything and see if now it's fine. + name = name.downcase + return name if name =~ NAME_REGEXP + + # Let's strip extra characters from the beginning and end. first = name.index(/[a-z0-9]/) return nil if first.nil? last = name.rindex(/[a-z0-9]/) diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index cf89e0b53..fc6ee5fb4 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -180,6 +180,10 @@ expect(Namespace.make_valid("ma_s")).to eq "ma_s" expect(Namespace.make_valid("!lol!")).to eq "lol" expect(Namespace.make_valid("!lol!name")).to eq "lol_name" + expect(Namespace.make_valid("Miquel.Sabate")).to eq "miquel.sabate" + expect(Namespace.make_valid("Miquel.Sabate.")).to eq "miquel.sabate" + expect(Namespace.make_valid("M")).to eq "m" + expect(Namespace.make_valid("_M_")).to eq "m" end end end