Fix #5730 - Ignore null/undef. values in uri.appendParams
This commit is contained in:
@@ -10,9 +10,14 @@ goog.provide('ol.uri');
|
|||||||
* @return {string} The new URI.
|
* @return {string} The new URI.
|
||||||
*/
|
*/
|
||||||
ol.uri.appendParams = function(uri, params) {
|
ol.uri.appendParams = function(uri, params) {
|
||||||
var qs = Object.keys(params).map(function(k) {
|
var keyParams = [];
|
||||||
return k + '=' + encodeURIComponent(params[k]);
|
// Skip any null or undefined parameter values
|
||||||
}).join('&');
|
Object.keys(params).forEach(function(k) {
|
||||||
|
if (params[k] !== null && params[k] !== undefined) {
|
||||||
|
keyParams.push(k + '=' + encodeURIComponent(params[k]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var qs = keyParams.join('&');
|
||||||
// remove any trailing ? or &
|
// remove any trailing ? or &
|
||||||
uri = uri.replace(/[?&]$/, '');
|
uri = uri.replace(/[?&]$/, '');
|
||||||
// append ? or & depending on whether uri has existing parameters
|
// append ? or & depending on whether uri has existing parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user