Fix Style/SlicingWithRange
cop (#25923)
This commit is contained in:
parent
658742b3cd
commit
b8b2470cf8
12 changed files with 13 additions and 28 deletions
|
@ -25,7 +25,7 @@ class AccountAlias < ApplicationRecord
|
|||
|
||||
def acct=(val)
|
||||
val = val.to_s.strip
|
||||
super(val.start_with?('@') ? val[1..-1] : val)
|
||||
super(val.start_with?('@') ? val[1..] : val)
|
||||
end
|
||||
|
||||
def pretty_acct
|
||||
|
|
|
@ -69,7 +69,7 @@ class DomainBlock < ApplicationRecord
|
|||
|
||||
uri = Addressable::URI.new.tap { |u| u.host = domain.strip.delete('/') }
|
||||
segments = uri.normalized_host.split('.')
|
||||
variants = segments.map.with_index { |_, i| segments[i..-1].join('.') }
|
||||
variants = segments.map.with_index { |_, i| segments[i..].join('.') }
|
||||
|
||||
where(domain: variants).order(Arel.sql('char_length(domain) desc')).first
|
||||
rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError
|
||||
|
|
|
@ -64,7 +64,7 @@ class EmailDomainBlock < ApplicationRecord
|
|||
|
||||
segments = uri.normalized_host.split('.')
|
||||
|
||||
segments.map.with_index { |_, i| segments[i..-1].join('.') }
|
||||
segments.map.with_index { |_, i| segments[i..].join('.') }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -54,6 +54,6 @@ class PreviewCardProvider < ApplicationRecord
|
|||
|
||||
def self.matching_domain(domain)
|
||||
segments = domain.split('.')
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..-1].join('.') }).order(Arel.sql('char_length(domain) desc')).first
|
||||
where(domain: segments.map.with_index { |_, i| segments[i..].join('.') }).order(Arel.sql('char_length(domain) desc')).first
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue