This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-12-26 00:38:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DomainNormalizable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2020-05-31 21:47:20 -04:00
|
|
|
before_validation :normalize_domain
|
2018-12-26 00:38:42 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def normalize_domain
|
2019-02-02 21:59:51 -05:00
|
|
|
self.domain = TagManager.instance.normalize_domain(domain&.strip)
|
2022-11-14 02:07:14 -05:00
|
|
|
rescue Addressable::URI::InvalidURIError
|
|
|
|
errors.add(:domain, :invalid)
|
2018-12-26 00:38:42 -05:00
|
|
|
end
|
|
|
|
end
|