What version of Go are you using (go version)?
go version go1.19rc1 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
package main
import "net/url"
func main() {
u, err := url.JoinPath("https://www.example.com/a%2fb", "a%2fb")
if err != nil {
panic(err)
}
print(u)
}
https://go.dev/play/p/YS_-s65X9n2?v=gotip
What did you expect to see?
https://www.example.com/a%2fb/a%2fb
What did you see instead?
https://www.example.com/a/b/a%2fb
How to fix
In the JoinPath method,
elem = append([]string{u.Path}, elem...)
should be written as
elem = append([]string{u.EscapedPath()}, elem...)