]> Cypherpunks repositories - gostls13.git/commitdiff
net/url: document, test that PathEscape escapes / to %2F
authorRuss Cox <rsc@golang.org>
Thu, 25 Apr 2019 15:43:52 +0000 (11:43 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 26 Apr 2019 13:52:08 +0000 (13:52 +0000)
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>
src/net/url/url.go
src/net/url/url_test.go

index b7e8beec75acc43b92cae4d2430ad4aede84de72..5f40555bdcea7a1d110583e3ce2c28ffa284ce1d 100644 (file)
@@ -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)
 }
index c5fc90d5156fd9f0a73b1dc3066abf9355ffddb6..27e132b1cd16f495935baacad11970df3f030368 100644 (file)
@@ -929,6 +929,11 @@ var pathEscapeTests = []EscapeTest{
                "abc+def",
                nil,
        },
+       {
+               "a/b",
+               "a%2Fb",
+               nil,
+       },
        {
                "one two",
                "one%20two",