discourse/app/services/wildcard_url_checker.rb

13 lines
251 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module WildcardUrlChecker
def self.check_url(url, url_to_check)
escaped_url = Regexp.escape(url).sub("\\*", '\S*')
url_regex = Regexp.new("^#{escaped_url}$", 'i')
url_to_check.match(url_regex)
end
end