Skip to content

Commit 51254f0

Browse files
committed
Fix URL query parsing in Firefox.
Closes bug 14686.
1 parent 7ed93e6 commit 51254f0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

‎pkgs/scribble-pkgs/scribble-lib/scribble/scribble-common.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
// Page Parameters ------------------------------------------------------------
44

5-
var page_query_string =
6-
(location.href.search(/\?([^#]+)(?:#|$)/) >= 0) && RegExp.$1;
5+
var page_query_string = location.search.substring(1);
76

87
var page_args =
98
((function(){
@@ -32,13 +31,16 @@ function MergePageArgsIntoLink(a) {
3231
}
3332

3433
function MergePageArgsIntoUrl(href) {
35-
href.search(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
36-
if (RegExp.$2.length == 0) {
37-
return RegExp.$1 + "?" + page_query_string + RegExp.$3;
38-
} else {
34+
var mtch = href.match(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
35+
if (mtch == undefined) { // I think this never happens
36+
return "?" + page_query_string;
37+
}
38+
if (!mtch[2]) {
39+
return mtch[1] + "?" + page_query_string + (mtch[3] || "");
40+
}
3941
// need to merge here, precedence to arguments that exist in `a'
4042
var i, j;
41-
var prefix = RegExp.$1, str = RegExp.$2, suffix = RegExp.$3;
43+
var prefix = mtch[1], str = mtch[2] || "", suffix = mtch[3] || "";
4244
var args = str.split(/[&;]/);
4345
for (i=0; i<args.length; i++) {
4446
j = args[i].indexOf('=');
@@ -52,7 +54,6 @@ function MergePageArgsIntoUrl(href) {
5254
if (!exists) str += "&" + page_args[i][0] + "=" + page_args[i][1];
5355
}
5456
return prefix + "?" + str + suffix;
55-
}
5657
}
5758

5859
// Cookies --------------------------------------------------------------------

0 commit comments

Comments
 (0)