Allow other params than 'mode' in example query string.
Currently, if other params are present at the beginning of the query string, the mode switcher will not work. This situation can occur when a search criteria was entered in the examples index page. That criteria will be passed along to the example page via a query param.
This commit is contained in:
@@ -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('&');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user