mirror of https://github.com/golang/go.git
net/url: document, test that PathEscape escapes / to %2F
I couldn't remember and couldn't tell from the docs, so I added a test and documented what I found. Change-Id: Ic5d837c2d620b15d7a831823e94e70080f5e5324 Reviewed-on: https://go-review.googlesource.com/c/go/+/173948 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
216797b63b
commit
a7dc6ca4b1
|
|
@ -276,8 +276,8 @@ func QueryEscape(s string) string {
|
|||
return escape(s, encodeQueryComponent)
|
||||
}
|
||||
|
||||
// PathEscape escapes the string so it can be safely placed
|
||||
// inside a URL path segment.
|
||||
// PathEscape escapes the string so it can be safely placed inside a URL path segment,
|
||||
// replacing special characters (including /) with %XX sequences as needed.
|
||||
func PathEscape(s string) string {
|
||||
return escape(s, encodePathSegment)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -929,6 +929,11 @@ var pathEscapeTests = []EscapeTest{
|
|||
"abc+def",
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"a/b",
|
||||
"a%2Fb",
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"one two",
|
||||
"one%20two",
|
||||
|
|
|
|||
Loading…
Reference in New Issue