From 8d54b6e6158592c29e40fed12f394efab56f85ea Mon Sep 17 00:00:00 2001 From: Graeme Arthur <2030310+graeme@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:57:42 +0100 Subject: [PATCH] Pass TLD as parameter --- .../SecureVault/PartialFormSaveManager.swift | 6 ++++++ .../SecureVault/SecureVaultManager.swift | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/BrowserServicesKit/SecureVault/PartialFormSaveManager.swift b/Sources/BrowserServicesKit/SecureVault/PartialFormSaveManager.swift index 41e94ab8d..c497bf86d 100644 --- a/Sources/BrowserServicesKit/SecureVault/PartialFormSaveManager.swift +++ b/Sources/BrowserServicesKit/SecureVault/PartialFormSaveManager.swift @@ -24,6 +24,12 @@ final class PartialFormSaveManager { private static var accounts: [String: WebsiteAccount] = .init() + private let tld: TLD + + init(tld: TLD) { + self.tld = tld + } + func partialAccount(forDomain domain: String) -> WebsiteAccount? { guard let tldPlus1 = TLD().eTLDplus1(domain) else { return nil diff --git a/Sources/BrowserServicesKit/SecureVault/SecureVaultManager.swift b/Sources/BrowserServicesKit/SecureVault/SecureVaultManager.swift index 303272961..ed9c69168 100644 --- a/Sources/BrowserServicesKit/SecureVault/SecureVaultManager.swift +++ b/Sources/BrowserServicesKit/SecureVault/SecureVaultManager.swift @@ -123,7 +123,7 @@ public class SecureVaultManager { private var autogeneratedCredentials: Bool { return autogeneratedUserName || autogeneratedPassword } - private let partialFormSaveManager = PartialFormSaveManager() + private let partialFormSaveManager: PartialFormSaveManager public lazy var autofillWebsiteAccountMatcher: AutofillWebsiteAccountMatcher? = { guard let tld = tld else { return nil } @@ -141,6 +141,11 @@ public class SecureVaultManager { self.includePartialAccountMatches = includePartialAccountMatches self.shouldAllowPartialFormSaves = shouldAllowPartialFormSaves self.tld = tld + if let tld { + partialFormSaveManager = PartialFormSaveManager(tld: tld) + } else { + partialFormSaveManager = PartialFormSaveManager(tld: TLD()) + } } }