fmt.Println(url.JoinPath("https://go.dev", "../x")) // https://go.dev/../x
fmt.Println(url.JoinPath("https://go.dev/", "../x")) // https://go.dev/x
https://go.dev/play/p/gLLv0cc_jn1
JoinPath doesn't remove ../ path components appended to a domain that is not terminated by a slash. This is surprising and could conceivably lead to a directory traversal attack. The result of JoinPath shouldn't depend on whether the first component is / terminated or not.
Thanks to @q0jt for reporting this bug.