X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fjson-replacers.js;h=2160ad8635af71f9aed3fbd169c02cd17df71849;hb=HEAD;hp=51eacb3cb5f2c8a259ce0bf55496ec64391fbb79;hpb=8f067f063e2410dd72bcd51aee69b273b1915c25;p=squeep-logger-json-console diff --git a/lib/json-replacers.js b/lib/json-replacers.js index 51eacb3..0ccea72 100644 --- a/lib/json-replacers.js +++ b/lib/json-replacers.js @@ -8,9 +8,9 @@ const http = require('node:http'); /** * Convert any Error to a plain Object. - * @param {String} _key - * @param {*} value - * @returns {Object} + * @param {string} _key key, unused + * @param {*} value value to possibly replace + * @returns {object} value or replaced value */ function replacerError(_key, value) { if (value instanceof Error) { @@ -24,9 +24,9 @@ function replacerError(_key, value) { /** * Convert any BigInt type to a String. - * @param {String} _key - * @param {*} value - * @returns {String} + * @param {string} _key key, unused + * @param {*} value value to possibly replace + * @returns {string} value or replaced value */ function replacerBigInt(_key, value) { if (typeof value === 'bigint') { @@ -41,9 +41,9 @@ function replacerBigInt(_key, value) { * Also sanitizes any Authorization header. We do this here rather than * in sanitization stage so that we do not have to rely on a set path to * this object. - * @param {String} _key - * @param {*} value - * @returns {Object} + * @param {string} _key key, unused + * @param {*} value value to possibly replace + * @returns {object} value or replaved value */ function replacerHttpIncomingMessage(_key, value) { if (value instanceof http.IncomingMessage) { @@ -62,9 +62,10 @@ function replacerHttpIncomingMessage(_key, value) { // This blurs entire auth string if no space found, because -1 from indexOf. const blurredAuthHeader = authHeader.slice(0, spaceIndex + 1) + '*'.repeat(authHeader.length - (spaceIndex + 1)); // New headers object, as we change it. - newValue.headers = Object.assign({}, newValue.headers, { + newValue.headers = { + ...newValue.headers, authorization: blurredAuthHeader, - }); + }; } value = newValue; } @@ -74,9 +75,9 @@ function replacerHttpIncomingMessage(_key, value) { /** * Convert any ServerResponse or OutgoingMessage to a subset Object. - * @param {String} _key - * @param {*} value - * @returns {Object} + * @param {string} _key key, unused + * @param {*} value value to possibly replace + * @returns {object} value or replaced value */ function replacerHttpServerResponse(_key, value) { if (value instanceof http.OutgoingMessage || value instanceof http.ServerResponse) {