Skip to content

Commit

Permalink
Update to selection logic to take subdomains into account
Browse files Browse the repository at this point in the history
  • Loading branch information
amddg44 committed Jan 3, 2024
1 parent f6f7ac4 commit b498fd9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,19 @@ final class PasswordManagementItemListModel: ObservableObject {
func selectLoginWithDomainOrFirst(domain: String, notify: Bool = true) {
let websiteAccounts = items
.compactMap { $0.websiteAccount }
let bestMatch = websiteAccounts.sortedForDomain(domain, tld: ContentBlocking.shared.tld, removeDuplicates: true)

// If the best match does not include the TLD, just pick the first item in the list
if let match = bestMatch.first,
tld.eTLDplus1(domain) == tld.eTLDplus1(match.domain) {
let matchingAccounts = websiteAccounts.filter { account in
return urlMatcher.isMatchingForAutofill(
currentSite: domain,
savedSite: account.domain ?? "",
tld: tld
)
}

let bestMatch = matchingAccounts.sortedForDomain(domain, tld: tld, removeDuplicates: true)

// If there are no matches for autofill, just pick the first item in the list
if let match = bestMatch.first {

for section in displayedItems {
if let account = section.items.first(where: {
Expand Down

0 comments on commit b498fd9

Please sign in to comment.