Remove URL.Opaque

This commit is contained in:
Richard Patel 2018-11-16 01:53:16 +01:00
parent f668365edb
commit ccaf758e90
No known key found for this signature in database
GPG Key ID: C268B2BBDA2ABECB

View File

@ -326,7 +326,6 @@ func escape(s string, mode encoding) string {
// by calling the EscapedPath method. // by calling the EscapedPath method.
type URL struct { type URL struct {
Scheme Scheme Scheme Scheme
Opaque string // encoded opaque data
Host string // host or host:port Host string // host or host:port
Path string // path (relative paths may omit leading slash) Path string // path (relative paths may omit leading slash)
} }
@ -446,7 +445,6 @@ func (u *URL) parse(rawurl string, viaRequest bool) error {
if !strings.HasPrefix(rest, "/") { if !strings.HasPrefix(rest, "/") {
if u.Scheme != SchemeInvalid { if u.Scheme != SchemeInvalid {
// We consider rootless paths per RFC 3986 as opaque. // We consider rootless paths per RFC 3986 as opaque.
u.Opaque = rest
return nil return nil
} }
if viaRequest { if viaRequest {
@ -588,9 +586,6 @@ func (u *URL) String() string {
buf.WriteString(Schemes[u.Scheme]) buf.WriteString(Schemes[u.Scheme])
buf.WriteByte(':') buf.WriteByte(':')
} }
if u.Opaque != "" {
buf.WriteString(u.Opaque)
} else {
if u.Scheme != SchemeInvalid || u.Host != "" { if u.Scheme != SchemeInvalid || u.Host != "" {
if u.Host != "" || u.Path != "" { if u.Host != "" || u.Path != "" {
buf.WriteString("//") buf.WriteString("//")
@ -615,7 +610,6 @@ func (u *URL) String() string {
} }
} }
buf.WriteString(path) buf.WriteString(path)
}
return buf.String() return buf.String()
} }
@ -694,11 +688,6 @@ func (u *URL) ResolveReference(url *URL, ref *URL) {
url.Path = resolvePath(ref.Path, "") url.Path = resolvePath(ref.Path, "")
return return
} }
if ref.Opaque != "" {
url.Host = ""
url.Path = ""
return
}
// The "abs_path" or "rel_path" cases. // The "abs_path" or "rel_path" cases.
url.Host = u.Host url.Host = u.Host
url.Path = resolvePath(u.Path, ref.Path) url.Path = resolvePath(u.Path, ref.Path)