Convert relative URLs to absolute
Anirudh Oppiliappan x@icyphox.sh
Thu, 30 Sep 2021 11:41:24 +0530
3 files changed,
13 insertions(+),
4 deletions(-)
M
go.mod
→
go.mod
@@ -4,11 +4,12 @@ go 1.16
require ( blitiri.com.ar/go/spf v1.2.0 + git.icyphox.sh/rel2abs v0.0.0-20210930060148-3afa938cbb82 github.com/go-shiori/go-readability v0.0.0-20210627123243-82cc33435520 github.com/gomodule/redigo v1.8.5 github.com/joho/godotenv v1.3.0 github.com/microcosm-cc/bluemonday v1.0.15 github.com/xhit/go-simple-mail/v2 v2.10.0 - golang.org/x/net v0.0.0-20210908191846-a5e095526f91 + golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 mvdan.cc/xurls/v2 v2.3.0 )
M
go.sum
→
go.sum
@@ -1,6 +1,8 @@
blitiri.com.ar/go/spf v1.2.0 h1:aPpeEVKz5Ue4xb4SEt4AzScCSyES7/pol6znzZGle3A= blitiri.com.ar/go/spf v1.2.0/go.mod h1:HLmgHxdrsqbBgi5omEopdAKm18PypvUKJGkF/j7BO0w= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +git.icyphox.sh/rel2abs v0.0.0-20210930060148-3afa938cbb82 h1:R2qbJvpnAWPfZx/Hav99zC5azCvQXexESqZKf5mnz+c= +git.icyphox.sh/rel2abs v0.0.0-20210930060148-3afa938cbb82/go.mod h1:5c6aNXPIujL/Z+NuGbulUhMK4wct37zs1dh/N3V+k4Q= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=@@ -136,8 +138,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20210505214959-0714010a04ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210908191846-a5e095526f91 h1:E8wdt+zBjoxD3MA65wEc3pl25BsTi7tbkpwc4ANThjc= -golang.org/x/net v0.0.0-20210908191846-a5e095526f91/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 h1:eDd+TJqbgfXruGQ5sJRU7tEtp/58OAx4+Ayjxg4SM+4= +golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
M
mail/send.go
→
mail/send.go
@@ -8,6 +8,7 @@ "mime"
"os" "git.icyphox.sh/forlater/navani/reader" + "git.icyphox.sh/rel2abs" "github.com/joho/godotenv" mail "github.com/xhit/go-simple-mail/v2" )@@ -26,7 +27,12 @@ if err != nil {
return err } - plainContent, err := reader.MakePlaintext(htmlContent) + htmlAbs, err := rel2abs.Convert(htmlContent, article.URL.String()) + if err != nil { + htmlAbs = htmlContent + } + + plainContent, err := reader.MakePlaintext(htmlAbs) if err != nil { return fmt.Errorf("making plaintext: %w\n", err) }