Descriptionnet/url: Fix regression from issue 11698045:
I belive the current fix is not 100% correct (or at least it breaks a use case that used to work before the fix).
The following test used to return "a/b/c" and now it returns "/a/b/c" (i.e. a relative URL becomes absolute):
func main() {
path := "a/b/c"
u, _ := url.Parse(path)
fmt.Println("path:", path)
fmt.Println("url:", u)
}
I understand the root problem but I think the correct fix should be to also check that the buffer is not empty (i.e. if I do create a URL with schema/host and a relative path I DO WANT the "/", but if the URL only has the Path set, it should be left alone).
Also, I don't see any test for this particular use case
The fix only prepend a "/" if the buffer is not empty (i.e. it should have scheme:host).
Also reworked the test case (added a new TestURLToString test and added a list of urltostringtests, for now containing only the two cases involved with this issue)
Patch Set 1 #Patch Set 2 : diff -r 1d23464b2d2f https://code.google.com/p/go #Patch Set 3 : diff -r 1d23464b2d2f https://code.google.com/p/go #
MessagesTotal messages: 6
|