Skip to content

Commit 26b0bb6

Browse files
committed
in case a request parameter is a parseable date string, cast it to iso string before logging
1 parent 3c9ecc7 commit 26b0bb6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

api.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ const serverOptions = {
121121
key = key.substr(0, 30) + '…';
122122
}
123123

124+
try {
125+
// if the param is a date ensure it gets sent as an ISO String to logging
126+
const possibleDate = new Date(value); // Value guaranteed to be string
127+
if (!isNaN(possibleDate.getTime()) && possibleDate.toString() !== 'Invalid Date') {
128+
// valid date
129+
value = possibleDate.toISOString();
130+
}
131+
} catch {
132+
// ignore
133+
}
134+
124135
message['_req_' + key] = value;
125136
});
126137

0 commit comments

Comments
 (0)