all repos — rel2abs @ 3afa938cbb8276652d033528e499b183d7aecb12

go library to convert all relative urls in a html document to absolute ones

Rename to Convert
Anirudh Oppiliappan x@icyphox.sh
Thu, 30 Sep 2021 11:31:48 +0530
commit

3afa938cbb8276652d033528e499b183d7aecb12

parent

dce15cb59ed63defbcef744d34a5e18a83ac1824

2 files changed, 2 insertions(+), 2 deletions(-)

jump to
M readmereadme

@@ -15,7 +15,7 @@ )

func main() { htmlRel := `<html><body><a href="#footnote-1">[1]</a></body></html>` - htmlAbs, err := rel2abs.Rel2Abs([]byte(htmlRel), "http://foo.com/bar") + htmlAbs, err := rel2abs.Convert([]byte(htmlRel), "http://foo.com/bar") fmt.Println(htmlAbs) // <html><body><a href="http://foo.com/bar#footnote-1">[1]</a></body></html>
M rel2abs.gorel2abs.go

@@ -30,7 +30,7 @@ }

// Converts all relative URLs in htmlContent to absolute URLs, // resolved against a base URL. -func Rel2Abs(htmlContent []byte, base string) ([]byte, error) { +func Convert(htmlContent []byte, base string) ([]byte, error) { doc, err := html.Parse(bytes.NewReader(htmlContent)) if err != nil { return nil, fmt.Errorf("html parse: %w\n", err)