class WebMock::URIAddressablePattern

def add_query_params(query_params)

def add_query_params(query_params)
  @@add_query_params_warned ||= false
  if not @@add_query_params_warned
    @@add_query_params_warned = true
    warn "WebMock warning: ignoring query params in RFC 6570 template and checking them with WebMock"
  end
  super(query_params)
end

def matches_with_variations?(uri)

def matches_with_variations?(uri)
  template =
    begin
      Addressable::Template.new(WebMock::Util::URI.heuristic_parse(@pattern.pattern))
    rescue Addressable::URI::InvalidURIError
      Addressable::Template.new(@pattern.pattern)
    end
  WebMock::Util::URI.variations_of_uri_as_strings(uri).any? { |u|
    template_matches_uri?(template, u)
  }
end

def pattern_inspect

def pattern_inspect
  @pattern.pattern.inspect
end

def pattern_matches?(uri)

def pattern_matches?(uri)
  if @query_params.nil?
    # Let Addressable check the whole URI
    matches_with_variations?(uri)
  else
    # WebMock checks the query, Addressable checks everything else
    matches_with_variations?(uri.omit(:query))
  end
end

def template_matches_uri?(template, uri)

def template_matches_uri?(template, uri)
  template.match(uri)
rescue Addressable::URI::InvalidURIError
  false
end