diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/scribble-common.js b/pkgs/scribble-pkgs/scribble-lib/scribble/scribble-common.js index 75c7fcd0..efbba097 100644 --- 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; }