Merge pull request #3183 from htulipe/switch-mode-fix
Allow other params than 'mode' in example page query string.
This commit is contained in:
@@ -29,11 +29,13 @@
|
|||||||
pairs = [],
|
pairs = [],
|
||||||
i,
|
i,
|
||||||
pair,
|
pair,
|
||||||
adjusted;
|
adjusted,
|
||||||
|
modeFound = false;
|
||||||
for (i = chunks.length - 1; i >= 0; --i) {
|
for (i = chunks.length - 1; i >= 0; --i) {
|
||||||
pair = chunks[i].split('=');
|
pair = chunks[i].split('=');
|
||||||
if (pair[0].toLowerCase() === 'mode') {
|
if (pair[0].toLowerCase() === 'mode') {
|
||||||
pair[1] = newMode;
|
pair[1] = newMode;
|
||||||
|
modeFound = true;
|
||||||
}
|
}
|
||||||
adjusted = encodeURIComponent(pair[0]);
|
adjusted = encodeURIComponent(pair[0]);
|
||||||
if (typeof pair[1] !== undefined) {
|
if (typeof pair[1] !== undefined) {
|
||||||
@@ -41,8 +43,8 @@
|
|||||||
}
|
}
|
||||||
pairs.push(adjusted);
|
pairs.push(adjusted);
|
||||||
}
|
}
|
||||||
if (pairs.length === 0) {
|
if (!modeFound) {
|
||||||
pairs[0] = 'mode=' + encodeURIComponent(newMode);
|
pairs.push('mode=' + encodeURIComponent(newMode));
|
||||||
}
|
}
|
||||||
location.href = baseUrl + '?' + pairs.join('&');
|
location.href = baseUrl + '?' + pairs.join('&');
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user