nested options and using it

This commit is contained in:
Simon Martín
2017-12-18 12:34:56 +01:00
parent cb7fb97a13
commit a46f7b3099
+9 -6
View File
@@ -187,7 +187,7 @@ function setErrorHeader(errors, statusCode, res) {
};
});
res.set('X-Tiler-Errors', JSON.stringify(errorsLog));
res.set('X-Tiler-Errors', stringifyForLogs(errorsLog));
}
/**
@@ -198,13 +198,16 @@ function setErrorHeader(errors, statusCode, res) {
*/
function stringifyForLogs(object) {
Object.keys(object).map(key => {
const value = object[key];
if (object instanceof Object) {
stringifyForLogs(value);
} else {
if (typeof object[key] === 'object') {
stringifyForLogs(object[key]);
} else if (object[key] instanceof Array) {
for (let element of object[key]) {
stringifyForLogs(element);
}
} else if(typeof object[key] === 'string') {
object[key] = object[key].replace(/[^a-zA-Z0-9]/g, ' ');
}
});
return JSON.stringify(object);
}
}