From 09b61f06c11fa63e4b1d6785afcd8769d6411972 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 27 Apr 2021 16:13:40 -0600 Subject: [PATCH] search page: avoid propagating "q" query When you search in a page other than the main search page, the search request is communicated as a "q" query in the URL. Meanwhile, the search page generally propagates all query arguments, as a kind of store-passing facility, which means that the "q" query was passed along. Avoid adding the "q" to search results, so it doesn't get propagated so much. Closes #936 --- .../scribblings/main/private/search.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/racket-index/scribblings/main/private/search.js b/pkgs/racket-index/scribblings/main/private/search.js index 5606e0ed52..e75336cea6 100644 --- a/pkgs/racket-index/scribblings/main/private/search.js +++ b/pkgs/racket-index/scribblings/main/private/search.js @@ -679,11 +679,23 @@ function UncompactHtml(x) { } } +function StripQArg(args) { + // Don't propagate the `q=...` argument that is used to communicate + // to this search page + if (!args) + return false; + args = args.replace(/^[?]q=[^&]*&/,"?").replace(/^[?]q=[^&]*$/,"?").replace(/&q=[^&]*/,""); + if (args == "?") + return false; + else + return args; +} + function UpdateResults() { if (first_search_result < 0 || first_search_result >= search_results.length) first_search_result = 0; - var link_args = (page_query_string && ("?"+page_query_string)); + var link_args = page_query_string && StripQArg("?"+page_query_string); for (var i=0; i