Skip to content

Commit 51a23d6

Browse files
committed
net/url: clarify RawPath documentation
Consistently recommend using EscapedPath rather than RawPath directly. For golang#33596. Change-Id: Ibe5c2dfa7fe6b1fbc540efed6db1291fc6532726 Reviewed-on: https://go-review.googlesource.com/c/go/+/418035 Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent beebd53 commit 51a23d6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/net/url/url.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,14 @@ func escape(s string, mode encoding) string {
351351
// Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.
352352
// A consequence is that it is impossible to tell which slashes in the Path were
353353
// slashes in the raw URL and which were %2f. This distinction is rarely important,
354-
// but when it is, the code should use RawPath, an optional field which only gets
355-
// set if the default encoding is different from Path.
354+
// but when it is, the code should use the EscapedPath method, which preserves
355+
// the original encoding of Path.
356356
//
357-
// URL's String method uses the EscapedPath method to obtain the path. See the
358-
// EscapedPath method for more details.
357+
// The RawPath field is an optional field which is only set when the default
358+
// encoding of Path is different from the escaped path. See the EscapedPath method
359+
// for more details.
360+
//
361+
// URL's String method uses the EscapedPath method to obtain the path.
359362
type URL struct {
360363
Scheme string
361364
Opaque string // encoded opaque data

0 commit comments

Comments
 (0)