Merge pull request #3183 from htulipe/switch-mode-fix

Allow other params than 'mode' in example page query string.
This commit is contained in:
Éric Lemoine
2015-01-28 16:03:25 +01:00

View File

@@ -29,11 +29,13 @@
pairs = [],
i,
pair,
adjusted;
adjusted,
modeFound = false;
for (i = chunks.length - 1; i >= 0; --i) {
pair = chunks[i].split('=');
if (pair[0].toLowerCase() === 'mode') {
pair[1] = newMode;
modeFound = true;
}
adjusted = encodeURIComponent(pair[0]);
if (typeof pair[1] !== undefined) {
@@ -41,8 +43,8 @@
}
pairs.push(adjusted);
}
if (pairs.length === 0) {
pairs[0] = 'mode=' + encodeURIComponent(newMode);
if (!modeFound) {
pairs.push('mode=' + encodeURIComponent(newMode));
}
location.href = baseUrl + '?' + pairs.join('&');
};