diff --git a/Library/Homebrew/search.rb b/Library/Homebrew/search.rb index 606fad7e362d9..b33a4ccbf1250 100644 --- a/Library/Homebrew/search.rb +++ b/Library/Homebrew/search.rb @@ -150,7 +150,7 @@ def self.search(selectable, string_or_regex, &block) end def self.simplify_string(string) - string.downcase.gsub(/[^a-z\d]/i, "") + string.downcase.gsub(/[^a-z\d@+]/i, "") end def self.search_regex(selectable, regex) diff --git a/Library/Homebrew/test/search_spec.rb b/Library/Homebrew/test/search_spec.rb index 39b10cb7dc9ad..aa0ba3ec9ee3a 100644 --- a/Library/Homebrew/test/search_spec.rb +++ b/Library/Homebrew/test/search_spec.rb @@ -20,7 +20,7 @@ end describe "#search" do - let(:collection) { ["with-dashes"] } + let(:collection) { ["with-dashes", "with@alpha", "with+plus"] } context "when given a block" do let(:collection) { [["with-dashes", "withdashes"]] } @@ -41,6 +41,11 @@ it "simplifies both the query and searched strings" do expect(described_class.search(collection, "with dashes")).to eq ["with-dashes"] end + + it "does not simplify strings with @ and + characters" do + expect(described_class.search(collection, "with@alpha")).to eq ["with@alpha"] + expect(described_class.search(collection, "with+plus")).to eq ["with+plus"] + end end context "when searching a Hash" do