about summary refs log tree commit diff stats
path: root/internal/server
diff options
context:
space:
mode:
authorAlan Pearce2025-03-19 17:41:48 +0100
committerAlan Pearce2025-03-19 17:41:48 +0100
commit9102aef53c5fb73585359306a518e726a3623731 (patch)
treeea2b451a527551540f684ece91b18020532e2f1d /internal/server
parent896d844cac976afd0ee8aa73dd2fb28e15e7ac79 (diff)
downloadsearchix-9102aef53c5fb73585359306a518e726a3623731.tar.lz
searchix-9102aef53c5fb73585359306a518e726a3623731.tar.zst
searchix-9102aef53c5fb73585359306a518e726a3623731.zip
fix: wrong pagination links for combined results
Fixes: https://todo.sr.ht/~alanpearce/searchix/15
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/mux.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/server/mux.go b/internal/server/mux.go
index 2bbff8e..f7a82d8 100644
--- a/internal/server/mux.go
+++ b/internal/server/mux.go
@@ -82,7 +82,9 @@ func NewMux(
 		return func(w http.ResponseWriter, r *http.Request) {
 			var err error
 			var source *config.Source
+			var urlBase string
 			if importerType != config.All {
+				urlBase = "search"
 				source = cfg.Importer.Sources[r.PathValue("source")]
 				if source == nil || importerType != source.Importer {
 					errorHandler(w, r, http.StatusText(http.StatusNotFound), http.StatusNotFound)
@@ -151,7 +153,7 @@ func NewMux(
 
 					if page.Next != 0 {
 						q.Set("page", strconv.Itoa(page.Next))
-						tdata.Next = "search?" + q.Encode()
+						tdata.Next = urlBase + "?" + q.Encode()
 					}
 
 					if page.Prev != 0 {
@@ -160,11 +162,11 @@ func NewMux(
 						} else {
 							q.Set("page", strconv.Itoa(page.Prev))
 						}
-						tdata.Prev = "search?" + q.Encode()
+						tdata.Prev = urlBase + "?" + q.Encode()
 					}
 
 					q.Set("page", "0")
-					tdata.All = "search?" + q.Encode()
+					tdata.All = urlBase + "?" + q.Encode()
 				}
 
 				w.Header().Add("Cache-Control", "max-age=300")