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>
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)
}
"abc+def",
nil,
},
+ {
+ "a/b",
+ "a%2Fb",
+ nil,
+ },
{
"one two",
"one%20two",