Module: Urlmatch
- Defined in:
- lib/urlmatch.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.urlmatch(pattern, url) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/urlmatch.rb', line 6 def self.urlmatch(pattern, url) # (scheme)://(domain)/(path) regex = /\A(\*|https|http):\/\/(\*|\*\.[^\*\/]+|[^\*\/]+)\/(.*)\z/ @@pattern_match = regex.match(pattern) raise Error, "Invalid Match Pattern: #{pattern}" unless @@pattern_match url_regex = /\A#{scheme}:\/\/#{domain}\/#{path}\z/ !!url_regex.match(url) end |