Commit 2f8d94fe authored by David Symonds's avatar David Symonds

net/url: regularise receiver names.

Update #2946.

R=golang-dev, bradfitz, bradfitz
CC=golang-dev
https://golang.org/cl/5674065
parent 7ec5499d
...@@ -589,15 +589,15 @@ func (u *URL) IsAbs() bool { ...@@ -589,15 +589,15 @@ func (u *URL) IsAbs() bool {
return u.Scheme != "" return u.Scheme != ""
} }
// Parse parses a URL in the context of a base URL. The URL in ref // Parse parses a URL in the context of the receiver. The provided URL
// may be relative or absolute. Parse returns nil, err on parse // may be relative or absolute. Parse returns nil, err on parse
// failure, otherwise its return value is the same as ResolveReference. // failure, otherwise its return value is the same as ResolveReference.
func (base *URL) Parse(ref string) (*URL, error) { func (u *URL) Parse(ref string) (*URL, error) {
refurl, err := Parse(ref) refurl, err := Parse(ref)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return base.ResolveReference(refurl), nil return u.ResolveReference(refurl), nil
} }
// ResolveReference resolves a URI reference to an absolute URI from // ResolveReference resolves a URI reference to an absolute URI from
...@@ -606,13 +606,13 @@ func (base *URL) Parse(ref string) (*URL, error) { ...@@ -606,13 +606,13 @@ func (base *URL) Parse(ref string) (*URL, error) {
// URL instance, even if the returned URL is identical to either the // URL instance, even if the returned URL is identical to either the
// base or reference. If ref is an absolute URL, then ResolveReference // base or reference. If ref is an absolute URL, then ResolveReference
// ignores base and returns a copy of ref. // ignores base and returns a copy of ref.
func (base *URL) ResolveReference(ref *URL) *URL { func (u *URL) ResolveReference(ref *URL) *URL {
if ref.IsAbs() { if ref.IsAbs() {
url := *ref url := *ref
return &url return &url
} }
// relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ] // relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
url := *base url := *u
url.RawQuery = ref.RawQuery url.RawQuery = ref.RawQuery
url.Fragment = ref.Fragment url.Fragment = ref.Fragment
if ref.Opaque != "" { if ref.Opaque != "" {
...@@ -632,7 +632,7 @@ func (base *URL) ResolveReference(ref *URL) *URL { ...@@ -632,7 +632,7 @@ func (base *URL) ResolveReference(ref *URL) *URL {
url.Path = ref.Path url.Path = ref.Path
} else { } else {
// The "rel_path" case. // The "rel_path" case.
path := resolvePath(base.Path, ref.Path) path := resolvePath(u.Path, ref.Path)
if !strings.HasPrefix(path, "/") { if !strings.HasPrefix(path, "/") {
path = "/" + path path = "/" + path
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment