1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[PM-18219] Normalize blocked domain checks to a common util (#13416)

* normalize blocked domain checks to common util

* do not use currentTabIsOnBlocklist$ in showCurrentTabIsBlockedBanner$ resolution

* update additional vault popup autofill service cases to use isUrlInList

* cleanup and use Utils get hostname instead of tldts directly
This commit is contained in:
Jonathan Prusik
2025-02-21 13:15:02 -05:00
committed by GitHub
parent 0bc7813b1c
commit 2e96405f15
5 changed files with 145 additions and 45 deletions

View File

@@ -70,6 +70,7 @@ import {
UserNotificationSettingsService,
UserNotificationSettingsServiceAbstraction,
} from "@bitwarden/common/autofill/services/user-notification-settings.service";
import { isUrlInList } from "@bitwarden/common/autofill/utils";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { DefaultBillingAccountProfileStateService } from "@bitwarden/common/billing/services/account/billing-account-profile-state.service";
import { ClientType } from "@bitwarden/common/enums";
@@ -1384,18 +1385,11 @@ export default class MainBackground {
const tab = await BrowserApi.getTabFromCurrentWindow();
if (tab) {
const currentUriIsBlocked = await firstValueFrom(
const currentUrlIsBlocked = await firstValueFrom(
this.domainSettingsService.blockedInteractionsUris$.pipe(
map((blockedInteractionsUris) => {
if (blockedInteractionsUris && tab?.url?.length) {
const tabURL = new URL(tab.url);
const tabIsBlocked = Object.keys(blockedInteractionsUris).some((blockedHostname) =>
tabURL.hostname.endsWith(blockedHostname),
);
if (tabIsBlocked) {
return true;
}
map((blockedInteractionsUrls) => {
if (blockedInteractionsUrls && tab?.url?.length) {
return isUrlInList(tab.url, blockedInteractionsUrls);
}
return false;
@@ -1403,7 +1397,7 @@ export default class MainBackground {
),
);
await this.cipherContextMenuHandler?.update(tab.url, currentUriIsBlocked);
await this.cipherContextMenuHandler?.update(tab.url, currentUrlIsBlocked);
this.onUpdatedRan = this.onReplacedRan = false;
}
}