summaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'client.go')
-rw-r--r--client.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/client.go b/client.go
index 74fe04c..217a777 100644
--- a/client.go
+++ b/client.go
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
+ "net/url"
neturl "net/url"
"tildegit.org/tjp/sliderule/finger"
@@ -86,7 +87,7 @@ func (c Client) Fetch(url string) (*Response, error) {
}
prev := u
- u, err = neturl.Parse(getRedirectLocation(u.Scheme, response.Meta))
+ u, err = neturl.Parse(getRedirectLocation(prev, u.Scheme, response.Meta))
if err != nil {
return nil, err
}
@@ -112,10 +113,11 @@ func (c Client) Upload(url string, contents io.Reader) (*Response, error) {
}
}
-func getRedirectLocation(proto string, meta any) string {
+func getRedirectLocation(prev *url.URL, proto string, meta any) string {
switch proto {
case "gemini", "spartan":
- return meta.(string)
+ u, _ := url.Parse(meta.(string))
+ return prev.ResolveReference(u).String()
case "http", "https":
return meta.(*http.Response).Header.Get("Location")
}