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
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)
The text was updated successfully, but these errors were encountered:
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).
by raff367:
The text was updated successfully, but these errors were encountered: