From 6860beba288db52ad24f1b40d4be1e01d6880994 Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 2 Apr 2021 17:49:00 +0300 Subject: [PATCH] The url property could be type of string --- src/index.js | 2 +- src/utils.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 9f3cbaa..5a3e6f0 100755 --- a/src/index.js +++ b/src/index.js @@ -33,7 +33,7 @@ async function main() { let programs = [] console.log('Parsing:') for (let item of queue) { - const url = config.url(item) + const url = typeof config.url === 'function' ? config.url(item) : config.url if (options.debug) console.time(' time') const progs = await client .get(url) diff --git a/src/utils.js b/src/utils.js index f37618c..d8df815 100644 --- a/src/utils.js +++ b/src/utils.js @@ -21,8 +21,8 @@ utils.loadConfig = function (file) { if (!config.site) throw new Error("The required 'site' property is missing") if (!config.channels) throw new Error("The required 'channels' property is missing") if (!config.url) throw new Error("The required 'url' property is missing") - if (typeof config.url !== 'function') - throw new Error("The 'url' property should return the function") + if (typeof config.url !== 'function' && typeof config.url !== 'string') + throw new Error("The 'url' property should return the function or string") if (!config.parser) throw new Error("The required 'parser' function is missing") if (typeof config.parser !== 'function') throw new Error("The 'parser' property should return the function")