module Mmtrix::Agent::HTTPClients::URIUtil

Constants

QUESTION_MARK

Public Class Methods

filter_uri(original) click to toggle source
# File lib/mmtrix/agent/http_clients/uri_util.rb, line 16
def self.filter_uri(original)
  filtered = original.dup
  filtered.user = nil
  filtered.password = nil
  filtered.query = nil
  filtered.fragment = nil
  filtered.to_s
end
parse_url(url) click to toggle source

There are valid URI strings that some HTTP client libraries will accept that the stdlib URI module doesn’t handle. If we find that Addressable is around, use that to normalize out our URL’s.

# File lib/mmtrix/agent/http_clients/uri_util.rb, line 28
def self.parse_url(url)
  if defined?(::Addressable::URI)
    address = ::Addressable::URI.parse(url)
    address.normalize!
    URI.parse(address.to_s)
  else
    URI.parse(url)
  end
end
strip_query_string(fragment) click to toggle source
# File lib/mmtrix/agent/http_clients/uri_util.rb, line 40
def self.strip_query_string(fragment)
  if(fragment.include?(QUESTION_MARK))
    fragment.split(QUESTION_MARK).first
  else
    fragment
  end
end