diff options
author | spf13 <steve.francia@gmail.com> | 2013-11-09 01:33:00 -0500 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2013-11-09 01:33:00 -0500 |
commit | 90a902c843758bb0d4c6da5ace4b9a813ab3a10e (patch) | |
tree | 8c57bbc13bcccec83c7d1d80b469d09f631a1c08 /transform | |
parent | b69694a3aefbf6ddfbf110de29dbb26c7976eff4 (diff) |
fixing double slash during absurlify
Diffstat (limited to 'transform')
-rw-r--r-- | transform/absurl.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/transform/absurl.go b/transform/absurl.go index 5967e597e..80716f1b7 100644 --- a/transform/absurl.go +++ b/transform/absurl.go @@ -1,9 +1,10 @@ package transform import ( + "bytes" htmltran "code.google.com/p/go-html-transform/html/transform" "net/url" - "bytes" + "strings" ) func AbsURL(absURL string) (trs []link, err error) { @@ -13,11 +14,13 @@ func AbsURL(absURL string) (trs []link, err error) { return } + base := strings.TrimRight(baseURL.String(), "/") + var ( - srcdq = []byte(" src=\""+baseURL.String()+"/") - hrefdq = []byte(" href=\""+baseURL.String()+"/") - srcsq = []byte(" src='"+baseURL.String()+"/") - hrefsq = []byte(" href='"+baseURL.String()+"/") + srcdq = []byte(" src=\"" + base + "/") + hrefdq = []byte(" href=\"" + base + "/") + srcsq = []byte(" src='" + base + "/") + hrefsq = []byte(" href='" + base + "/") ) trs = append(trs, func(content []byte) []byte { content = bytes.Replace(content, []byte(" src=\"/"), srcdq, -1) |