Extend proxy test to test all URL rewriting cases.

This commit is contained in:
Daniel Smith
2014-09-04 12:28:47 -07:00
parent 6554ee96f7
commit b6f1f84875
2 changed files with 98 additions and 40 deletions

View File

@@ -178,11 +178,16 @@ func (t *proxyTransport) updateURLs(n *html.Node, sourceURL *url.URL) {
continue
}
// Is this URL relative?
if url.Host == "" || url.Host == sourceURL.Host {
if url.Host == "" {
url.Scheme = t.proxyScheme
url.Host = t.proxyHost
url.Path = path.Join(t.proxyPathPrepend, path.Dir(sourceURL.Path), url.Path, "/")
n.Attr[i].Val = url.String()
} else if url.Host == sourceURL.Host {
url.Scheme = t.proxyScheme
url.Host = t.proxyHost
url.Path = path.Join(t.proxyPathPrepend, url.Path)
n.Attr[i].Val = url.String()
}
}
}