Skip to content

Commit 957e840

Browse files
jonsgreenadarsh
authored andcommitted
Fixes bug with matching website with multiple domains configured
- adds wildcard to the end of the ILIKE match string and removes unneeded parens around interpolated domain
1 parent 0771c3b commit 957e840

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

app/models/website.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Website < ApplicationRecord
2626
DEFAULT = 'default'.freeze
2727

2828
def self.domain_match(domain)
29-
where(arel_table[:domains].matches("%#{(domain)}"))
29+
where(arel_table[:domains].matches("%#{domain}%"))
3030
end
3131

3232
def manual_purge

spec/models/website_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
rubyconf = create(:website, domains: 'www.rubyconf.org,www.rubyconf.com')
1212
_otherconf = create(:website)
1313
expect(Website.domain_match('rubyconf.com')).to contain_exactly(rubyconf)
14+
expect(Website.domain_match('rubyconf.org')).to contain_exactly(rubyconf)
1415
end
1516
end
1617
end

0 commit comments

Comments
 (0)