Skip to content

Instantly share code, notes, and snippets.

@xfalcox
Created October 18, 2016 15:33
Show Gist options
  • Save xfalcox/12bfc4c782efa7e7ef3023bab1b0c18d to your computer and use it in GitHub Desktop.
Save xfalcox/12bfc4c782efa7e7ef3023bab1b0c18d to your computer and use it in GitHub Desktop.
Ruby URI is strange
url = '//example.com?a=1'
#=> "//example.com?a=1"
uri = URI(url)
#=> #<URI::Generic //example.com?a=1>
uri.request_uri
#NoMethodError: undefined method `request_uri' for #<URI::Generic //example.com?a=1>
url = 'https://example.com?a=1'
#=> "https://example.com?a=1"
uri = URI(url)
=> #<URI::HTTPS https://example.com?a=1>
uri.request_uri
#=> "/?a=1"
# WAT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment