all repos — rel2abs @ 3afa938cbb8276652d033528e499b183d7aecb12

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

readme (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
rel2abs
-------

Go library to convert all relative URLs to absolute ones, resolved
against a specified base URL.


EXAMPLE

    import (
        "fmt"

        "git.icyphox.sh/rel2abs"
    )

    func main() {
        htmlRel := `<html><body><a href="#footnote-1">[1]</a></body></html>`
        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>
    }