Module: NewRelic::Agent::HTTPClients::URIUtil
- Defined in:
- lib/new_relic/agent/http_clients/uri_util.rb
Constant Summary collapse
- QUESTION_MARK =
'?'
Class Method Summary collapse
- .obfuscated_uri(url) ⇒ Object
-
.parse_and_normalize_url(url) ⇒ Object
There are valid URI strings that some HTTP client libraries will accept that the stdlib URI module doesn’t handle.
- .strip_query_string(fragment) ⇒ Object
Class Method Details
permalink .obfuscated_uri(url) ⇒ Object
[View source]
16 17 18 19 20 21 22 23 |
# File 'lib/new_relic/agent/http_clients/uri_util.rb', line 16 def self.(url) parse_and_normalize_url(url).tap do || .user = nil .password = nil .query = nil .fragment = nil end end |
permalink .parse_and_normalize_url(url) ⇒ Object
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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/new_relic/agent/http_clients/uri_util.rb', line 28 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&.downcase! uri end |
permalink .strip_query_string(fragment) ⇒ Object
[View source]
45 46 47 48 49 50 51 |
# File 'lib/new_relic/agent/http_clients/uri_util.rb', line 45 def self.strip_query_string(fragment) if fragment.include?(QUESTION_MARK) fragment.split(QUESTION_MARK).first else fragment end end |