diff options
author | sameerasw <[email protected]> | 2025-02-28 22:58:22 +0530 |
---|---|---|
committer | sameerasw <[email protected]> | 2025-02-28 22:58:22 +0530 |
commit | b8f577fe1568f74bae9e6b58edabd0ff7c26fcd2 (patch) | |
tree | 158ec80ef789fba1b3967ba16d5edc12e22dd0dd /inject-css.js | |
parent | 35f2ec8e814fd57629d3a7b4b784c71223e2cecd (diff) |
Fixed #3 by allowing files starting with + to have prefixes in the url.
Diffstat (limited to 'inject-css.js')
-rw-r--r-- | inject-css.js | 12 |
1 files changed, 7 insertions, 5 deletions
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"); |