Module: RailsMaint::PathMatcher

Defined in:
lib/rails_maint/path_matcher.rb

Class Method Summary collapse

Class Method Details

.any_match?(patterns, request_path) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rails_maint/path_matcher.rb', line 14

def self.any_match?(patterns, request_path)
  patterns.any? { |pattern| match?(pattern, request_path) }
end

.match?(pattern, request_path) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/rails_maint/path_matcher.rb', line 5

def self.match?(pattern, request_path)
  if pattern.end_with?('/*')
    prefix = pattern.chomp('/*')
    request_path.start_with?(prefix)
  else
    request_path == pattern
  end
end