From f5cf3f09a2c890dac3e380d3a7f7912aefa919d9 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:45:01 +0800 Subject: [PATCH] only attempt to get URL If it doesn't exist, it should silently fail. --- scripts/filters.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/filters.js b/scripts/filters.js index fbeaa43..2f7b321 100644 --- a/scripts/filters.js +++ b/scripts/filters.js @@ -22,19 +22,27 @@ export default class filters { @param {string} URL the current URL */ - async select(URL = window.location.href) { - let SELECTED = await (async () => { - // Get the filters. - let filter = await search(`filters`, URL, `URL`, 0.5, {"cloud": -1}); - - // If there are filters, then filter the URL. - return filter; - })(); - - if ((SELECTED && SELECTED != null && (typeof SELECTED).includes(`obj`)) ? (Object.keys(SELECTED)).length > 0 : false) { - this.one = (Object.entries(SELECTED))[0][1]; - return (this.one); + async select(URL) { + if (!URL) { + try { + URL = window.location.href; + } catch(err) {} }; + + if (URL) { + let SELECTED = await (async () => { + // Get the filters. + let filter = await search(`filters`, URL, `URL`, 0.5, {"cloud": -1}); + + // If there are filters, then filter the URL. + return filter; + })(); + + if ((SELECTED && SELECTED != null && (typeof SELECTED).includes(`obj`)) ? (Object.keys(SELECTED)).length > 0 : false) { + this.one = (Object.entries(SELECTED))[0][1]; + return (this.one); + }; + } }; /* Update all filters or just one.