addressable
addressable copied to clipboard
Inconsistent Addressable::URI#heuristic_parse behavior with schemaless URLs
I would expect Addressable::URI#heuristic_parse
to give the same results for the completely schemaless test.com
and the protocol-relative schemaless url //test.com
Expected:
uri = Addressable::URI.heuristic_parse("//test.com")
uri.scheme
=> "http"
uri.relative?
=> false
Actual:
uri = Addressable::URI.heuristic_parse("//test.com")
uri.scheme
=> nil
uri.relative?
=> true
Good point. I agree.
From https://github.com/sporkmonger/addressable/issues/401#issuecomment-777883236
I think it's worth calling out that Addressable's
heuristic_parse
does aim to hew quite closely to whatever browsers are doing in the address bar.
If I enter //test.com
in Google Chrome it tries to visit file:///test.com
. Firefox tries to visit file:////test.com
. Safari does a Google search for //test.com
😅
Related to https://github.com/sporkmonger/addressable/issues/356