From bfe28315a02745cc6b5c1c4696eedf6110c80fcf Mon Sep 17 00:00:00 2001 From: patrickkfkan Date: Sat, 23 Jan 2021 21:51:22 +0800 Subject: [PATCH] Cache discover options --- lib/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index cc076b4..a9ec4f8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -69,10 +69,16 @@ async function sanitizeDiscoverParams(params) { } async function getDiscoverOptions() { + if (cache.discoverOptions !== undefined) { + return cache.discoverOptions; + } const url = utils.getSiteUrl(); return fetch(url) .then( res => res.text() ) - .then( html => parser.parseDiscoverOptions(html) ); + .then( html => { + cache.discoverOptions = parser.parseDiscoverOptions(html); + return cache.discoverOptions; + }); } async function getImageFormat(idOrName) {