-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net/url: consider an empty base Path as equivalent to / in JoinPath
A Path that starts with / is absolute. A Path that starts with any other character is relative. The meaning of a Path of "" is not defined, but RequestURI converts a "" Path to "/" and an empty Path may represent a URL with just a hostname and no trailing / such as "http://localhost". Handle empty paths in the base URL of JoinPath consistently with RequestURI, so that joining to an empty base produces an absolute path rather than a relative one. u, _ := url.Parse("http://localhost") u = u.JoinPath("x") fmt.Println(u.Path) // "/x", not "x" Fixes #58605 Change-Id: Iacced9c173b0aa693800dd01caf774f3f9a66d56 Reviewed-on: https://go-review.googlesource.com/c/go/+/469935 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
2 changed files
with
114 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters