escape chars function
This commit is contained in:
@@ -189,3 +189,22 @@ function setErrorHeader(errors, statusCode, res) {
|
||||
|
||||
res.set('X-Tiler-Errors', JSON.stringify(errorsLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove problematic nested characters
|
||||
* from object for logs RegEx
|
||||
*
|
||||
* @param {Object} object
|
||||
*/
|
||||
function stringifyForLogs(object) {
|
||||
Object.keys(object).map(key => {
|
||||
const value = object[key];
|
||||
if (object instanceof Object) {
|
||||
stringifyForLogs(value);
|
||||
} else {
|
||||
object[key] = object[key].replace(/[^a-zA-Z0-9]/g, ' ');
|
||||
}
|
||||
});
|
||||
|
||||
return JSON.stringify(object);
|
||||
}
|
||||
Reference in New Issue
Block a user