From 1c1bfca2633acaa2759a2cfc790b54eb5930e0c4 Mon Sep 17 00:00:00 2001 From: William Martin Date: Wed, 22 Oct 2025 11:41:50 -0400 Subject: [PATCH] check for undefined chrome runtime (for easy Storybook mocking) --- .../services/phishing-detection.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/dirt/phishing-detection/services/phishing-detection.service.ts b/apps/browser/src/dirt/phishing-detection/services/phishing-detection.service.ts index b3875b12828..dd3e208572d 100644 --- a/apps/browser/src/dirt/phishing-detection/services/phishing-detection.service.ts +++ b/apps/browser/src/dirt/phishing-detection/services/phishing-detection.service.ts @@ -37,7 +37,7 @@ export class PhishingDetectionService { "https://raw.githubusercontent.com/Phishing-Database/Phishing.Database/master/phishing-domains-ACTIVE.txt"; private static readonly RemotePhishingDatabaseChecksumUrl = "https://raw.githubusercontent.com/Phishing-Database/checksums/refs/heads/master/phishing-domains-ACTIVE.txt.md5"; - private static readonly LocalPhishingDatabaseUrl = chrome.runtime.getURL( + private static readonly LocalPhishingDatabaseUrl?: string = chrome?.runtime?.getURL( "dirt/phishing-detection/services/phishing-domains-ACTIVE.txt", ); /** This is tied to `./phishing-domainas-ACTIVE.txt` and should be updated in kind */ @@ -632,6 +632,9 @@ export class PhishingDetectionService { try { this._logService.info("[PhishingDetectionService] Fetching local DB as fallback"); + if (!this.LocalPhishingDatabaseUrl) { + throw new Error("No local database URL provided"); + } const fallbackDomains = await this._auditService.getKnownPhishingDomains( this.LocalPhishingDatabaseUrl, );