commit 4291016987898677abfa38158a1b3f4bb262af23
parent d2ccd737416f3aacc52de3d1ab7b92fe1cb764b2
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Mon, 5 May 2014 10:35:09 -0600
docs search: avoid accumulating "q" queries
original commit: 53e3d104f7adda1d94598ed498dec3b5f205e308
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/scribble-common.js b/pkgs/scribble-pkgs/scribble-lib/scribble/scribble-common.js
@@ -28,9 +28,13 @@ function MergePageArgsIntoLink(a) {
if (page_args.length == 0 ||
(!a.attributes["data-pltdoc"]) || (a.attributes["data-pltdoc"].value == ""))
return;
- a.href.search(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
+ a.href = MergePageArgsIntoUrl(a.href);
+}
+
+function MergePageArgsIntoUrl(href) {
+ href.search(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
if (RegExp.$2.length == 0) {
- a.href = RegExp.$1 + "?" + page_query_string + RegExp.$3;
+ return RegExp.$1 + "?" + page_query_string + RegExp.$3;
} else {
// need to merge here, precedence to arguments that exist in `a'
var i, j;
@@ -47,7 +51,7 @@ function MergePageArgsIntoLink(a) {
if (args[j] == page_args[i][0]) { exists = true; break; }
if (!exists) str += "&" + page_args[i][0] + "=" + page_args[i][1];
}
- a.href = prefix + "?" + str + suffix;
+ return prefix + "?" + str + suffix;
}
}
@@ -128,7 +132,7 @@ function DoSearchKey(event, field, ver, top_path) {
var u = GetCookie("PLT_Root."+ver, null);
if (u == null) u = top_path; // default: go to the top path
u += "search/index.html?q=" + escape(val);
- if (page_query_string) u += "&" + page_query_string;
+ u = MergePageArgsIntoUrl(u);
location = u;
return false;
}