From b5ca3a6cb1a0e46aef071195c61e1169c6574f03 Mon Sep 17 00:00:00 2001 From: Hiroki Sugawara Date: Fri, 26 Jan 2024 22:12:24 +0900 Subject: [PATCH] =?UTF-8?q?parameters.js=E3=81=AE=E3=83=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=AF=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/parameters.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/parameters.js b/lib/parameters.js index e0751fd..0eb30b2 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -32,17 +32,14 @@ function findOptionalArgs(opts, find) { } function getFetchOptions(isCrawler) { - const fetchOptions = {}; - const headers = { - 'accept': 'text/html', + const fetchOptions = { + headers: { + 'accept': 'text/html', + }, }; if (typeof isCrawler === 'boolean' && isCrawler) { - headers['user-agent'] = CRAWLER_USER_AGENT; - } - - if (Object.keys(headers).length !== 0) { - fetchOptions.headers = headers; + fetchOptions.headers['user-agent'] = CRAWLER_USER_AGENT; } return fetchOptions;