0
0
Fork 0

Extract by_domain_length scope in DomainNormalizable concern (#29517)

This commit is contained in:
Matt Jankowski 2024-03-12 09:09:11 -04:00 committed by GitHub
parent 5b60d4b696
commit d4ed7e466c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View file

@ -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