Skip to content

Commit

Permalink
allow @ and + characters for search
Browse files Browse the repository at this point in the history
  • Loading branch information
daeho-ro committed Sep 17, 2024
1 parent 42c11a4 commit 47e70ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion Library/Homebrew/test/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]] }
Expand All @@ -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
Expand Down

0 comments on commit 47e70ab

Please sign in to comment.