Optional chain for BreezeWiki custom host check

breezewiki-header-control
Kevin Payravi 2023-12-13 03:41:04 -06:00
parent b6c8a9559d
commit d477317467
1 changed files with 2 additions and 2 deletions

View File

@ -206,7 +206,7 @@ function displayRedirectBanner(newUrl, id, destinationName, destinationLanguage,
document.body.insertAdjacentElement('beforeBegin', banner);
// Increment banner count
if (storage.breezewiki === 'on') {
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost.includes(currentURL.hostname))) {
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost?.includes(currentURL.hostname))) {
chrome.storage.sync.set({ 'countAlerts': (storage.countAlerts ?? 0) + 1 });
}
} else {
@ -233,7 +233,7 @@ function main() {
if (currentURL.pathname.length > 1) {
let origin = currentURL;
// If on a BreezeWiki site, convert to Fandom link to match with our list of wikis:
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost.includes(currentURL.hostname))) {
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost?.includes(currentURL.hostname))) {
origin = String(currentURL.pathname).split('/')[1] + '.fandom.com/wiki/';
if (currentURL.search.includes('?q=')) {
origin = origin + currentURL.search.substring(3).split('&')[0];