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: regression from issue 11698045 #6609

Closed
gopherbot opened this issue Oct 17, 2013 · 3 comments
Closed

net/url: regression from issue 11698045 #6609

gopherbot opened this issue Oct 17, 2013 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by raff367:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

The test at http://play.golang.org/p/Yzayz9Fmuy returns different values in Go 1.2 vs.
Go 1.1.2

func main() {
        path := "a/b/c"
        u, _ := url.Parse(path)
        fmt.Println("path:", path)
        fmt.Println("url:", u.String())
 }

What is the expected output?

"a/b/c"

What do you see instead?

"/a/b/c"

Which version are you using?  (run 'go version')

go version devel +f4d1cb8d9a91 Thu Sep 19 22:34:33 2013 +1000 darwin/amd64

Please provide any additional information below.

The problem is caused by the "fix" for issue #11698045, that prepends a
"/" to the path in the String() method.
The correct fix is, I believe, to check if the buffer is empty or not. If it's empty the
original URL was a "relative URL" (no schema, no host, only path) in which
case the "/" should be omitted.

I have tested a fix, avaliable at https://golang.org/cl/14654045/
I have also updated the tests and added a new unit tests for similar cases ( build the
URL{} and check if String() returns the expected value)
@bradfitz
Copy link
Contributor

Comment 1:

I think this is a real regression.
The docs on Parse do say that it should accept relative URLs, but we have insufficient
test coverage on it.  We only have 1 test for relative URL (scheme-relative).

Labels changed: added go1.2, removed priority-triage.

Owner changed to @bradfitz.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 2:

https://golang.org/cl/14815043/

Status changed to Started.

@bradfitz
Copy link
Contributor

Comment 3:

This issue was closed by revision f41b43a.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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