*/
const generateETag = (_filePath, fileStat, fileData) => {
const hash = crypto.createHash('sha256');
- if (fileStat && fileStat.mtimeMs) {
+ if (fileStat?.mtimeMs) {
hash.update(fileStat.mtimeMs.toString());
}
hash.update(fileData);
* @deprecated after v1.2.5 (integrated into logger module)
*/
const scrubHeaderObject = (data) => {
- if (data && data.headers && 'authorization' in data.headers) {
+ if (data?.headers && 'authorization' in data.headers) {
data.headers = Object.assign({}, data.headers, {
authorization: obscureAuthorizationHeader(data.headers['authorization']),
});
if (type) {
let weight = 1.0;
params = params.reduce((acc, param) => {
- const [p, v] = common.splitFirst(param, '=').map((x) => x && x.trim());
+ const [p, v] = common.splitFirst(param, '=').map((x) => x?.trim());
if (p && v) {
if (p === 'q') {
weight = Number(v);
* @param {string} acceptHeader
*/
static _acceptClauses(acceptHeader) {
- const clauses = (acceptHeader||'').split(',').map((clause) => ContentNegotiation._unpackAcceptClause(clause)).filter((clause) => clause);
+ const clauses = (acceptHeader||'').split(',')
+ .map((clause) => ContentNegotiation._unpackAcceptClause(clause))
+ .filter((clause) => clause);
return clauses.sort((a, b) => b.weight - a.weight);
}