Module: Katello::Util::UrlMatcher

Defined in:
app/lib/katello/util/url_matcher.rb

Defined Under Namespace

Classes: Path, Pattern

Class Method Summary collapse

Class Method Details

.match(path, routes) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'app/lib/katello/util/url_matcher.rb', line 25

def self.match(path, routes)
  path     = Path.new(path)
  patterns = routes.map { |route| Pattern.new(Array(route).first) }

  patterns.each do |pattern|
    return [pattern.to_s] + pattern.vars if pattern == path
  end

  [nil]
end