Fix gemini gateway proxying to work with gateways like tildeverse's

This commit is contained in:
Brian Picciano 2023-09-21 10:51:30 +02:00
parent 78bbfa42fa
commit ba2d581975

View File

@ -7,7 +7,6 @@ import (
"io" "io"
"net/url" "net/url"
"path" "path"
"path/filepath"
"regexp" "regexp"
"strings" "strings"
) )
@ -50,11 +49,10 @@ func GemtextToMarkdown(dst io.Writer, src io.Reader, gmiGateway *url.URL) error
} }
if u.Scheme == "gemini" && gmiGateway != nil { if u.Scheme == "gemini" && gmiGateway != nil {
newUStr := gmiGateway.String() + u.Host + u.Path
newU := *gmiGateway if u, err = url.Parse(newUStr); err != nil {
newU.Path = filepath.Join(newU.Path, u.Host, u.Path) return fmt.Errorf("parsing proxied URL %q: %w", newUStr, err)
newU.RawQuery = u.RawQuery }
u = &newU
} }
isImg := hasImgExt(u.Path) isImg := hasImgExt(u.Path)