addressable icon indicating copy to clipboard operation
addressable copied to clipboard

Inconsistent Addressable::URI#heuristic_parse behavior with schemaless URLs

Open dwbutler opened this issue 6 years ago • 3 comments

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

dwbutler avatar Aug 01 '17 01:08 dwbutler

Good point. I agree.

sporkmonger avatar Aug 31 '19 03:08 sporkmonger

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 😅

dentarg avatar Jan 15 '22 13:01 dentarg

Related to https://github.com/sporkmonger/addressable/issues/356

dentarg avatar Jul 19 '23 08:07 dentarg