Merge pull request #18345 from daeho-ro/add-search-characters

search: allow @ and + characters
This commit is contained in:
Mike McQuaid 2024-09-17 08:48:28 +01:00 committed by GitHub
commit 6c39a5883f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -150,7 +150,7 @@ module Homebrew
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)

View File

@ -20,7 +20,7 @@ RSpec.describe Homebrew::Search do
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 @@ RSpec.describe Homebrew::Search do
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