You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
1.11
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
OS X
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
Tried to use url.Parse("www.uber.com/") and extract host in generic way. Appeared that host is empty and path is "www.uber.com/"
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
I looked at Unit Tests and found for instance:
// (starting with a scheme). Trying to parse a hostname and path
// without a scheme is invalid but may not necessarily return an
// error, due to parsing ambiguities.
What did you expect to see?
I think this should be able to parse correctly at least case like mine, this is pretty expected case.
What did you see instead?
Incorrect behavior, w/o error though.
The text was updated successfully, but these errors were encountered:
Sort of a duplicate of #12585, in any case working as intended. url.Parse is for parsing URLs; a URL starts with a scheme.
The point the comment is making that invalid URLs can look like valid URLs, for example localhost:1111 looks like a URL with the scheme localhost – it doesn't mean that url.Parse should go out of its way to support (guess!) certain invalid URLs.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.11
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?OS X
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
Tried to use url.Parse("www.uber.com/") and extract host in generic way. Appeared that host is empty and path is "www.uber.com/"
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
I looked at Unit Tests and found for instance:
So, in my case it failed because of empty schema.
I also added a UT for my case and it failed with:
ok net/textproto 0.014s
--- FAIL: TestParse (0.00s)
url_test.go:660: Parse("www.uber.com/"):
got opaque="", scheme="", user=, pass=, host="", path="www.uber.com/", rawpath="", rawq="", frag="", forcequery=false
want opaque="", scheme="", user=, pass=, host="www.uber.com", path="/", rawpath="", rawq="", frag="", forcequery=false
I see url.Parse comment says:
// (starting with a scheme). Trying to parse a hostname and path
// without a scheme is invalid but may not necessarily return an
// error, due to parsing ambiguities.
What did you expect to see?
I think this should be able to parse correctly at least case like mine, this is pretty expected case.
What did you see instead?
Incorrect behavior, w/o error though.
The text was updated successfully, but these errors were encountered: