module Doorkeeper::OAuth::Helpers::URIChecker

def self.as_uri(url)

def self.as_uri(url)
  URI.parse(url)
end

def self.matches?(url, client_url)

def self.matches?(url, client_url)
  url, client_url = as_uri(url), as_uri(client_url)
  url.query = nil
  url == client_url
end

def self.test_uri?(url)

def self.test_uri?(url)
  url == Doorkeeper.configuration.test_redirect_uri
end

def self.valid?(url)

def self.valid?(url)
  uri = as_uri(url)
  uri.fragment.nil? && !uri.host.nil? && !uri.scheme.nil?
rescue URI::InvalidURIError
  false
end

def self.valid_for_authorization?(url, client_url)

def self.valid_for_authorization?(url, client_url)
  valid?(url) && matches?(url, client_url)
end