2018-12-26 07:38:42 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DomainNormalizable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2020-06-01 04:47:20 +03:00
|
|
|
before_validation :normalize_domain
|
2018-12-26 07:38:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def normalize_domain
|
2019-02-03 04:59:51 +02:00
|
|
|
self.domain = TagManager.instance.normalize_domain(domain&.strip)
|
2022-11-14 09:07:14 +02:00
|
|
|
rescue Addressable::URI::InvalidURIError
|
|
|
|
errors.add(:domain, :invalid)
|
2018-12-26 07:38:42 +02:00
|
|
|
end
|
|
|
|
end
|