think i fixed url translation
alex wennerberg alex@alexwennerberg.com
Thu, 07 Jan 2021 00:15:17 -0800
1 files changed,
11 insertions(+),
11 deletions(-)
jump to
M
gmi2html.go
→
gmi2html.go
@@ -33,17 +33,17 @@ if err != nil {
continue } if reqUrl != nil { - // proxy - if u.Scheme == "gemini" || u.Scheme == "" { - if strings.HasSuffix(u.Host, c.Host) { - u.Scheme = "" - urlstring = html.EscapeString(u.String()) - } else { - u.Path = fmt.Sprintf("/%s%s", u.Host, u.Path) - u.Scheme = "" - u.Host = "proxy." + c.Host - urlstring = html.EscapeString(u.String()) - } + u = reqUrl.ResolveReference(u) + } + if u.Scheme == "gemini" || (reqUrl != nil && u.Scheme == "") { + if strings.HasSuffix(u.Host, c.Host) { + u.Scheme = "" + urlstring = html.EscapeString(u.String()) + } else { + u.Path = fmt.Sprintf("/%s%s", u.Host, u.Path) + u.Scheme = "" + u.Host = "proxy." + c.Host + urlstring = html.EscapeString(u.String()) } } name := html.EscapeString(link.Name)