From 446a6e8fa160483e1c48a575e60a636c9f37927a Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Wed, 19 Jul 2023 11:28:15 -0700 Subject: [PATCH] lint cleanup --- lib/common.js | 4 ++-- lib/content-negotiation.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/common.js b/lib/common.js index e2e2a8c..60e0d20 100644 --- a/lib/common.js +++ b/lib/common.js @@ -38,7 +38,7 @@ const fileScope = (filename) => { */ 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); @@ -197,7 +197,7 @@ const requestLogData = (req) => { * @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']), }); diff --git a/lib/content-negotiation.js b/lib/content-negotiation.js index 1425852..4401374 100644 --- a/lib/content-negotiation.js +++ b/lib/content-negotiation.js @@ -20,7 +20,7 @@ class ContentNegotiation { 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); @@ -47,7 +47,9 @@ class ContentNegotiation { * @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); } -- 2.43.2