mirror of
https://github.com/benbusby/farside.git
synced 2025-04-25 13:10:02 +00:00
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.
This commit is contained in:
parent
37b0df5c36
commit
4b19ad5228
2 changed files with 7 additions and 9 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue