From b8f577fe1568f74bae9e6b58edabd0ff7c26fcd2 Mon Sep 17 00:00:00 2001 From: sameerasw Date: Fri, 28 Feb 2025 22:58:22 +0530 Subject: Fixed #3 by allowing files starting with + to have prefixes in the url. --- inject-css.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'inject-css.js') diff --git a/inject-css.js b/inject-css.js index fc1fc0f..3246255 100644 --- a/inject-css.js +++ b/inject-css.js @@ -19,12 +19,14 @@ if (logging) console.log("inject-css.js script loaded"); const currentUrl = window.location.hostname; if (logging) console.log("Current URL hostname", currentUrl); - const cssFileName = Object.keys(data.styles?.website || {}).find( - (key) => { - const siteName = key.replace(".css", ""); - return currentUrl === siteName || currentUrl === `www.${siteName}`; + const cssFileName = Object.keys(data.styles?.website || {}).find((key) => { + const siteName = key.replace(".css", ""); + if (siteName.startsWith("+")) { + const baseSiteName = siteName.slice(1); + return currentUrl.endsWith(baseSiteName); } - ); + return currentUrl === siteName || currentUrl === `www.${siteName}`; + }); if (!cssFileName) { if (logging) console.log("No CSS file found for current site"); -- cgit v1.2.3