]> Cypherpunks repositories - gostls13.git/commitdiff
net/url: clarify RawPath documentation
authorDamien Neil <dneil@google.com>
Mon, 18 Jul 2022 15:51:32 +0000 (08:51 -0700)
committerDamien Neil <dneil@google.com>
Tue, 9 Aug 2022 18:43:28 +0000 (18:43 +0000)
Consistently recommend using EscapedPath rather than RawPath directly.

For #33596.

Change-Id: Ibe5c2dfa7fe6b1fbc540efed6db1291fc6532726
Reviewed-on: https://go-review.googlesource.com/c/go/+/418035
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/net/url/url.go

index e82ae6aeefd552d78efdee4f270ef37afc167357..a21af7e47958b0be1d525513f3d6d0f6aaa55c4b 100644 (file)
@@ -351,11 +351,14 @@ func escape(s string, mode encoding) string {
 // Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.
 // A consequence is that it is impossible to tell which slashes in the Path were
 // slashes in the raw URL and which were %2f. This distinction is rarely important,
-// but when it is, the code should use RawPath, an optional field which only gets
-// set if the default encoding is different from Path.
+// but when it is, the code should use the EscapedPath method, which preserves
+// the original encoding of Path.
 //
-// URL's String method uses the EscapedPath method to obtain the path. See the
-// EscapedPath method for more details.
+// The RawPath field is an optional field which is only set when the default
+// encoding of Path is different from the escaped path. See the EscapedPath method
+// for more details.
+//
+// URL's String method uses the EscapedPath method to obtain the path.
 type URL struct {
        Scheme      string
        Opaque      string    // encoded opaque data