summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorBen Busby <contact@benbusby.com>2025-02-25 11:20:13 -0700
committerBen Busby <contact@benbusby.com>2025-02-25 11:20:13 -0700
commit4b19ad5228a3a8c47bc9fa1a246b9cdffbc9c49f (patch)
tree6a952ec1959b66781c5be8e1d654cef198270ccd /server
parent37b0df5c36ad152ce285c013de0c6ed21a7aeeb9 (diff)
downloadfarside-4b19ad5228a3a8c47bc9fa1a246b9cdffbc9c49f.tar.gz
Include original url query in redirect
Query params were previously getting ignored in farside redirects, this updates the routing to append the original url query params to the end of the redirected instance.
Diffstat (limited to 'server')
-rw-r--r--server/server.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/server.go b/server/server.go
index a002662..b4ebb80 100644
--- a/server/server.go
+++ b/server/server.go
@@ -3,6 +3,7 @@ package server
import (
_ "embed"
"encoding/json"
+ "fmt"
"html/template"
"log"
"net/http"
@@ -61,22 +62,22 @@ func state(w http.ResponseWriter, r *http.Request) {
}
func baseRouting(w http.ResponseWriter, r *http.Request) {
- routing(w, r, false)
+ routing(w, r, false, r.URL.RawQuery)
}
func jsRouting(w http.ResponseWriter, r *http.Request) {
r.URL.Path = strings.Replace(r.URL.Path, "/_", "", 1)
- routing(w, r, true)
+ routing(w, r, true, r.URL.RawQuery)
}
-func routing(w http.ResponseWriter, r *http.Request, jsEnabled bool) {
+func routing(w http.ResponseWriter, r *http.Request, jsEnabled bool, query string) {
value := r.PathValue("routing")
if len(value) == 0 {
value = r.URL.Path
}
- url, _ := url.Parse(value)
- path := strings.TrimPrefix(url.Path, "/")
+ parsedURL, _ := url.Parse(value)
+ path := strings.TrimPrefix(parsedURL.Path, "/")
segments := strings.Split(path, "/")
if len(segments[0]) == 0 {
@@ -119,6 +120,7 @@ func routing(w http.ResponseWriter, r *http.Request, jsEnabled bool) {
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
+ instance += fmt.Sprintf("?%s", query)
if jsEnabled {
data := routeData{
InstanceURL: instance,