module NewRelic::Agent::HTTPClients::URIUtil
Constants
- QUESTION_MARK
Public Class Methods
Source
# File lib/new_relic/agent/http_clients/uri_util.rb, line 15 def self.obfuscated_uri(url) parse_and_normalize_url(url).tap do |obfuscated| obfuscated.user = nil obfuscated.password = nil obfuscated.query = nil obfuscated.fragment = nil end end
Source
# File lib/new_relic/agent/http_clients/uri_util.rb, line 27 def self.parse_and_normalize_url(url) uri = url.dup unless ::URI === uri if defined?(::Addressable::URI) address = ::Addressable::URI.parse(url) address.normalize! uri = ::URI.parse(address.to_s) else uri = ::URI.parse(url) end end uri.host = uri.host&.downcase uri end
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.
Source
# File lib/new_relic/agent/http_clients/uri_util.rb, line 44 def self.strip_query_string(fragment) if fragment.include?(QUESTION_MARK) fragment.split(QUESTION_MARK).first else fragment end end