discourse/app/services/wildcard_domain_checker.rb

11 lines
293 B
Ruby
Raw Normal View History

module WildcardDomainChecker
def self.check_domain(domain, external_domain)
escaped_domain = domain[0] == "*" ? Regexp.escape(domain).sub("\\*", '\S*') : Regexp.escape(domain)
domain_regex = Regexp.new("^#{escaped_domain}$", 'i')
external_domain.match(domain_regex)
end
end