Logs for testing
Anirudh Oppiliappan x@icyphox.sh
Sun, 26 Sep 2021 15:49:21 +0530
1 files changed,
2 insertions(+),
4 deletions(-)
jump to
M
rel2abs.go
→
rel2abs.go
@@ -13,11 +13,13 @@ if n.Type == html.ElementNode && n.Data == "a" {
for _, a := range n.Attr { if a.Key == "href" { rel, err := url.Parse(a.Val) + fmt.Println("rel:", rel) if err != nil { return fmt.Errorf("relative url: %w\n", err) } a.Val = nurl.ResolveReference(rel).String() + fmt.Println("resolved:", a.Val) } } for c := n.FirstChild; c != nil; c = c.NextSibling {@@ -29,10 +31,6 @@ }
// Converts all relative URLs in htmlContent to absolute URLs, // resolved against a base URL. -// Example, with base as http://example.com/foo: -// <a href="#fn-1"> -// becomes -// <a href="http://example.com/foo#fn-1"> func Rel2Abs(htmlContent []byte, base string) ([]byte, error) { doc, err := html.Parse(bytes.NewReader(htmlContent)) if err != nil {