Use consistent calling style for TagManager#normalize_domain (#35764)
This commit is contained in:
parent
9762b4a75c
commit
7e5e96739f
@ -54,7 +54,7 @@ module Admin
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Allow transparently upgrading a domain block
|
# Allow transparently upgrading a domain block
|
||||||
if existing_domain_block.present? && existing_domain_block.domain == TagManager.instance.normalize_domain(@domain_block.domain.strip)
|
if existing_domain_block.present? && existing_domain_block.domain == TagManager.instance.normalize_domain(@domain_block.domain)
|
||||||
@domain_block = existing_domain_block
|
@domain_block = existing_domain_block
|
||||||
@domain_block.assign_attributes(resource_params)
|
@domain_block.assign_attributes(resource_params)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -34,8 +34,11 @@ class Admin::Instances::ModerationNotesController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_instance
|
def set_instance
|
||||||
domain = params[:instance_id]&.strip
|
@instance = Instance.find_or_initialize_by(domain: normalized_domain)
|
||||||
@instance = Instance.find_or_initialize_by(domain: TagManager.instance.normalize_domain(domain))
|
end
|
||||||
|
|
||||||
|
def normalized_domain
|
||||||
|
TagManager.instance.normalize_domain(params[:instance_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_instance_note
|
def set_instance_note
|
||||||
|
|||||||
@ -55,8 +55,11 @@ module Admin
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_instance
|
def set_instance
|
||||||
domain = params[:id]&.strip
|
@instance = Instance.find_or_initialize_by(domain: normalized_domain)
|
||||||
@instance = Instance.find_or_initialize_by(domain: TagManager.instance.normalize_domain(domain))
|
end
|
||||||
|
|
||||||
|
def normalized_domain
|
||||||
|
TagManager.instance.normalize_domain(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_instances
|
def set_instances
|
||||||
|
|||||||
@ -47,10 +47,6 @@ class Api::V1::Peers::SearchController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def normalized_domain
|
def normalized_domain
|
||||||
TagManager.instance.normalize_domain(query_value)
|
TagManager.instance.normalize_domain(params[:q])
|
||||||
end
|
|
||||||
|
|
||||||
def query_value
|
|
||||||
params[:q].strip
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,9 +17,9 @@ class TagManager
|
|||||||
def normalize_domain(domain)
|
def normalize_domain(domain)
|
||||||
return if domain.nil?
|
return if domain.nil?
|
||||||
|
|
||||||
uri = Addressable::URI.new
|
Addressable::URI.new.tap do |uri|
|
||||||
uri.host = domain.strip.delete_suffix('/')
|
uri.host = domain.strip.delete_suffix('/')
|
||||||
uri.normalized_host
|
end.normalized_host
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_url?(url)
|
def local_url?(url)
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module DomainNormalizable
|
|||||||
private
|
private
|
||||||
|
|
||||||
def normalize_domain
|
def normalize_domain
|
||||||
self.domain = TagManager.instance.normalize_domain(domain&.strip)
|
self.domain = TagManager.instance.normalize_domain(domain)
|
||||||
rescue Addressable::URI::InvalidURIError
|
rescue Addressable::URI::InvalidURIError
|
||||||
errors.add(:domain, :invalid)
|
errors.add(:domain, :invalid)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class ReportService < BaseService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def forward_to_domains
|
def forward_to_domains
|
||||||
@forward_to_domains ||= (@options[:forward_to_domains] || [@target_account.domain]).filter_map { |domain| TagManager.instance.normalize_domain(domain&.strip) }.uniq
|
@forward_to_domains ||= (@options[:forward_to_domains] || [@target_account.domain]).filter_map { |domain| TagManager.instance.normalize_domain(domain) }.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def reported_status_ids
|
def reported_status_ids
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user