Fix URL query parsing in Firefox.

Closes bug 14686.

original commit: 51254f06267fb13d734e43413ae44740f29d4891
This commit is contained in:
Sam Tobin-Hochstadt 2014-08-18 13:52:06 -04:00
parent 7be7c29080
commit 02cd00e03b

View File

@ -2,8 +2,7 @@
// Page Parameters ------------------------------------------------------------
var page_query_string =
(location.href.search(/\?([^#]+)(?:#|$)/) >= 0) && RegExp.$1;
var page_query_string = location.search.substring(1);
var page_args =
((function(){
@ -32,13 +31,16 @@ function MergePageArgsIntoLink(a) {
}
function MergePageArgsIntoUrl(href) {
href.search(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
if (RegExp.$2.length == 0) {
return RegExp.$1 + "?" + page_query_string + RegExp.$3;
} else {
var mtch = href.match(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/);
if (mtch == undefined) { // I think this never happens
return "?" + page_query_string;
}
if (!mtch[2]) {
return mtch[1] + "?" + page_query_string + (mtch[3] || "");
}
// need to merge here, precedence to arguments that exist in `a'
var i, j;
var prefix = RegExp.$1, str = RegExp.$2, suffix = RegExp.$3;
var prefix = mtch[1], str = mtch[2] || "", suffix = mtch[3] || "";
var args = str.split(/[&;]/);
for (i=0; i<args.length; i++) {
j = args[i].indexOf('=');
@ -52,7 +54,6 @@ function MergePageArgsIntoUrl(href) {
if (!exists) str += "&" + page_args[i][0] + "=" + page_args[i][1];
}
return prefix + "?" + str + suffix;
}
}
// Cookies --------------------------------------------------------------------