2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 01:03:53 -04:00
|
|
|
module WildcardDomainChecker
|
|
|
|
def self.check_domain(domain, external_domain)
|
2023-01-09 07:20:10 -05:00
|
|
|
escaped_domain =
|
|
|
|
domain[0] == "*" ? Regexp.escape(domain).sub("\\*", '\S*') : Regexp.escape(domain)
|
|
|
|
domain_regex = Regexp.new("\\A#{escaped_domain}\\z", "i")
|
2018-10-15 01:03:53 -04:00
|
|
|
|
|
|
|
external_domain.match(domain_regex)
|
|
|
|
end
|
|
|
|
end
|