Skip to content

Commit

Permalink
Fix query parameter concatenation when JavaScript is disabled
Browse files Browse the repository at this point in the history
fixes #116
  • Loading branch information
stapelberg committed Sep 29, 2022
1 parent a3edd9e commit e8b7f51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cmd/dcs-web/serverrendered.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func renderPerPackage(w http.ResponseWriter, r *http.Request, queryid string, pa

basequery.Del("perpkg")
basequery.Del("q")
// Ensure the filterurl has at least one parameter, so that we can
// always concatenate with the & sign.
basequery.Set("_", "_")
baseurl.RawQuery = basequery.Encode()
filterurl := baseurl.String()

Expand Down Expand Up @@ -328,6 +331,9 @@ func Search(w http.ResponseWriter, r *http.Request) {

basequery.Del("perpkg")
basequery.Del("q")
// Ensure the filterurl has at least one parameter, so that we can
// always concatenate with the & sign.
basequery.Set("_", "_")
baseurl.RawQuery = basequery.Encode()
filterurl := baseurl.String()

Expand Down
2 changes: 1 addition & 1 deletion cmd/dcs-web/templates/perpackage-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h2>Search Results by package for "{{.q}}"</h2>
<p>
<strong>Filter by package:</strong>
{{range $index, $package := .packages}}
<a href="{{$.filterurl}}?q={{$.q}}+package:{{$package}}">{{$package}}</a>,
<a href="{{$.filterurl}}&q={{$.q}}+package:{{$package}}">{{$package}}</a>,
{{end}}
</p>

Expand Down
2 changes: 1 addition & 1 deletion cmd/dcs-web/templates/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h2>Search Results for "{{.q}}"</h2>
<p>
<strong>Filter by package:</strong>
{{range $index, $package := .packages}}
<a href="{{$.filterurl}}?q={{$.q}}+package:{{$package}}">{{$package}}</a>,
<a href="{{$.filterurl}}&q={{$.q}}+package:{{$package}}">{{$package}}</a>,
{{end}}
</p>

Expand Down

0 comments on commit e8b7f51

Please sign in to comment.