Module: TingYun::Agent::HTTPClients::URIUtil
- Defined in:
- lib/ting_yun/support/http_clients/uri_util.rb
Constant Summary collapse
- QUESTION_MARK =
"?".freeze
Class Method Summary collapse
- .filter_uri(original) ⇒ Object
-
.parse_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
.filter_uri(original) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/ting_yun/support/http_clients/uri_util.rb', line 15 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) ⇒ 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.
27 28 29 30 31 32 33 34 35 |
# File 'lib/ting_yun/support/http_clients/uri_util.rb', line 27 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) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ting_yun/support/http_clients/uri_util.rb', line 39 def self.strip_query_string(fragment) if(fragment.include?(QUESTION_MARK)) fragment.split(QUESTION_MARK).first else fragment end end |