Method: Wpxf::Net::HttpClient#normalize_uri
- Defined in:
- lib/wpxf/net/http_client.rb
#normalize_uri(*parts) ⇒ String
Normalize a URI to remove duplicated slashes and ensure a slash at the start of the string if it doesn’t start with http:// or https://.
70 71 72 73 74 75 76 |
# File 'lib/wpxf/net/http_client.rb', line 70 def normalize_uri(*parts) path = parts * '/' path = '/' + path unless path.start_with?('/', 'http://', 'https://') url = URI.parse(path) url.path.squeeze!('/') url.to_s end |