Extract by_domain_length
scope in DomainNormalizable
concern (#29517)
This commit is contained in:
parent
5b60d4b696
commit
d4ed7e466c
4 changed files with 15 additions and 3 deletions
|
@ -70,7 +70,7 @@ class DomainBlock < ApplicationRecord
|
|||
segments = uri.normalized_host.split('.')
|
||||
variants = segments.map.with_index { |_, i| segments[i..].join('.') }
|
||||
|
||||
where(domain: variants).order(Arel.sql('char_length(domain) desc')).first
|
||||
where(domain: variants).by_domain_length.first
|
||||
rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError
|
||||
nil
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue