fixing double slash during absurlify

This commit is contained in:
spf13 2013-11-09 01:33:00 -05:00
parent b69694a3ae
commit 90a902c843

View file

@ -1,9 +1,10 @@
package transform package transform
import ( import (
"bytes"
htmltran "code.google.com/p/go-html-transform/html/transform" htmltran "code.google.com/p/go-html-transform/html/transform"
"net/url" "net/url"
"bytes" "strings"
) )
func AbsURL(absURL string) (trs []link, err error) { func AbsURL(absURL string) (trs []link, err error) {
@ -13,11 +14,13 @@ func AbsURL(absURL string) (trs []link, err error) {
return return
} }
base := strings.TrimRight(baseURL.String(), "/")
var ( var (
srcdq = []byte(" src=\""+baseURL.String()+"/") srcdq = []byte(" src=\"" + base + "/")
hrefdq = []byte(" href=\""+baseURL.String()+"/") hrefdq = []byte(" href=\"" + base + "/")
srcsq = []byte(" src='"+baseURL.String()+"/") srcsq = []byte(" src='" + base + "/")
hrefsq = []byte(" href='"+baseURL.String()+"/") hrefsq = []byte(" href='" + base + "/")
) )
trs = append(trs, func(content []byte) []byte { trs = append(trs, func(content []byte) []byte {
content = bytes.Replace(content, []byte(" src=\"/"), srcdq, -1) content = bytes.Replace(content, []byte(" src=\"/"), srcdq, -1)