summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-06 15:49:07 -0400
committerRuss Cox <rsc@golang.org>2014-10-06 15:49:07 -0400
commiteb32a44bc00a78ca46a69f57f600dd430c22cc2b (patch)
tree23989f907a833da46e633fea58780e80d8e15b6d /src/net
parent108521744f8607c55dff4fca73342d8e72219641 (diff)
downloadgo-eb32a44bc00a78ca46a69f57f600dd430c22cc2b.tar.gz
net/url: document result of String
Fixes issue 8742. LGTM=bradfitz R=golang-codereviews CC=adg, bradfitz, golang-codereviews, iant https://codereview.appspot.com/155910043
Diffstat (limited to 'src/net')
-rw-r--r--src/net/url/url.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/net/url/url.go b/src/net/url/url.go
index 0b32cd7c8..f167408fa 100644
--- a/src/net/url/url.go
+++ b/src/net/url/url.go
@@ -441,6 +441,24 @@ func parseAuthority(authority string) (user *Userinfo, host string, err error) {
}
// String reassembles the URL into a valid URL string.
+// The general form of the result is one of:
+//
+// scheme:opaque
+// scheme://userinfo@host/path?query#fragment
+//
+// If u.Opaque is non-empty, String uses the first form;
+// otherwise it uses the second form.
+//
+// In the second form, the following rules apply:
+// - if u.Scheme is empty, scheme: is omitted.
+// - if u.User is nil, userinfo@ is omitted.
+// - if u.Host is empty, host/ is omitted.
+// - if u.Scheme and u.Host are empty and u.User is nil,
+// the entire scheme://userinfo@host/ is omitted.
+// - if u.Host is non-empty and u.Path begins with a /,
+// the form host/path does not add its own /.
+// - if u.RawQuery is empty, ?query is omitted.
+// - if u.Fragment is empty, #fragment is omitted.
func (u *URL) String() string {
var buf bytes.Buffer
if u.Scheme != "" {