module Doorkeeper::OAuth::Helpers::URIChecker

def self.matches?(url, client_url)

def self.matches?(url, client_url)
  url = as_uri(url)
  client_url = as_uri(client_url)
  unless client_url.query.nil?
    return false unless query_matches?(url.query, client_url.query)
    # Clear out queries so rest of URI can be tested. This allows query
    # params to be in the request but order not mattering.
    client_url.query = nil
  end
  # RFC8252, Paragraph 7.3
  # @see https://datatracker.ietf.org/doc/html/rfc8252#section-7.3
  if loopback_uri?(url) && loopback_uri?(client_url)
    url.port = nil
    client_url.port = nil
  end
  url.query = nil
  url == client_url
end