Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/url: Parse generates incorrect Path if hostname is empty #4189

Closed
gopherbot opened this issue Oct 3, 2012 · 6 comments
Closed

net/url: Parse generates incorrect Path if hostname is empty #4189

gopherbot opened this issue Oct 3, 2012 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by Jens.Alfke:

url.Parse behaves incorrectly on a URL with an empty hostname, e.g.
"file:///foo". This URL is equivalent to "file://localhost/foo";, but
the resulting URL's Path will incorrectly be "///foo" instead of
"/foo".

What steps will reproduce the problem?
Run http://play.golang.org/p/CJJ1OU8QRq
The body of this is:
    url, _ := url.Parse("file://localhost/foo/bar";)
    fmt.Printf("When URL host is %q, path is %q\n", url.Host, url.Path)
    url, _ = url.Parse("file:///foo/bar")
    fmt.Printf("When URL host is %q, path is %q\n", url.Host, url.Path)

What is the expected output?
When URL host is "localhost", path is "/foo/bar"
When URL host is "", path is "/foo/bar"

What do you see instead?
When URL host is "localhost", path is "/foo/bar"
When URL host is "", path is "///foo/bar"

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g, I think (just using "go run")

Which operating system are you using?
Mac OS X 10.8.2

Which version are you using?  (run 'go version')
1.0.3
@rsc
Copy link
Contributor

rsc commented Oct 6, 2012

Comment 1:

Labels changed: added priority-later, go1.1, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 3:

Labels changed: added suggested.

@gopherbot
Copy link
Author

Comment 4 by alakriti:

I've submitted a patch to fix this issue. https://golang.org/cl/6931047

@adg
Copy link
Contributor

adg commented Jan 17, 2013

Comment 5:

I also submitted a patch, after the previous one lay dormant for 4 weeks:
https://golang.org/cl/7135051/

Labels changed: removed suggested.

Owner changed to @adg.

@adg
Copy link
Contributor

adg commented Jan 23, 2013

Comment 6:

This issue was closed by revision cdd6ae1.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants