From: Russ Cox Date: Thu, 25 Apr 2019 15:43:52 +0000 (-0400) Subject: net/url: document, test that PathEscape escapes / to %2F X-Git-Tag: go1.13beta1~544 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a7dc6ca4b176cc4a918a73ffd0ab7df92011fdbb;p=gostls13.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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/net/url/url.go b/src/net/url/url.go index b7e8beec75..5f40555bdc 100644 --- a/src/net/url/url.go +++ b/src/net/url/url.go @@ -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) } diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go index c5fc90d515..27e132b1cd 100644 --- a/src/net/url/url_test.go +++ b/src/net/url/url_test.go @@ -929,6 +929,11 @@ var pathEscapeTests = []EscapeTest{ "abc+def", nil, }, + { + "a/b", + "a%2Fb", + nil, + }, { "one two", "one%20two",