Fix proxy link regression
alex wennerberg alex@alexwennerberg.com
Thu, 07 Jan 2021 00:09:42 -0800
1 files changed,
12 insertions(+),
10 deletions(-)
jump to
M
gmi2html.go
→
gmi2html.go
@@ -32,16 +32,18 @@ u, err := url.Parse(urlstring)
if err != nil { continue } - u = reqUrl.ResolveReference(u) - 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()) + 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()) + } } } name := html.EscapeString(link.Name)