all repos — searchix @ 0f1f8e6b60a0aa8d615d1b4838abd71faf045c64

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix: 404 on detail pages

Alan Pearce
commit

0f1f8e6b60a0aa8d615d1b4838abd71faf045c64

parent

25c441dd75c2310b841fc9f3a175d5c445f0cd5e

1 file changed, 8 insertions(+), 0 deletions(-)

changed files
M internal/server/mux.gointernal/server/mux.go
@@ -86,6 +86,14 @@
mux.Handle("/all/search", http.RedirectHandler("/", http.StatusFound)) mux.Handle("/all/opensearch.xml", http.RedirectHandler("/opensearch.xml", http.StatusFound)) + for _, it := range []config.ImporterType{config.Options, config.Packages} { + singularPath := path.Join("/", it.Singular()) + mux.HandleFunc(singularPath+"/", func(w http.ResponseWriter, r *http.Request) { + newPath := path.Join("/", it.String(), strings.TrimPrefix(r.URL.Path, singularPath)) + http.Redirect(w, r, newPath, http.StatusFound) + }) + } + for _, source := range cfg.Importer.Sources { sh := handler.NewSourceHandler(source) importerPath := path.Join("/", source.Importer.String(), source.Key)