diff --git a/passAutoFillExtension/Controllers/CredentialProviderViewController.swift b/passAutoFillExtension/Controllers/CredentialProviderViewController.swift index da3bbc1..d15bcaa 100644 --- a/passAutoFillExtension/Controllers/CredentialProviderViewController.swift +++ b/passAutoFillExtension/Controllers/CredentialProviderViewController.swift @@ -38,8 +38,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController { credentialProvider.identifier = serviceIdentifiers.first let url = serviceIdentifiers.first.flatMap { URL(string: $0.identifier) } passwordsViewController.navigationItem.prompt = url?.host - let keywords = url?.host?.sanitizedDomain?.components(separatedBy: ".") ?? [] - passwordsViewController.showPasswordsWithSuggstion(keywords) + passwordsViewController.showPasswordsWithSuggstion(matching: url?.host ?? "") } override func provideCredentialWithoutUserInteraction(for credentialIdentity: ASPasswordCredentialIdentity) { @@ -57,7 +56,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController { } credentialProvider.identifier = credentialIdentity.serviceIdentifier passwordsViewController.navigationItem.prompt = identifier - passwordsViewController.showPasswordsWithSuggstion([identifier]) + passwordsViewController.showPasswordsWithSuggstion(matching: identifier) } } @@ -68,14 +67,3 @@ extension CredentialProviderViewController: PasswordSelectionDelegate { credentialProvider.persistAndProvideCredentials(with: passwordEntity.getPath()) } } - -private extension String { - var sanitizedDomain: String? { - replacingOccurrences(of: ".com", with: "") - .replacingOccurrences(of: ".org", with: "") - .replacingOccurrences(of: ".edu", with: "") - .replacingOccurrences(of: ".net", with: "") - .replacingOccurrences(of: ".gov", with: "") - .replacingOccurrences(of: "www.", with: "") - } -} diff --git a/passAutoFillExtension/Controllers/PasswordsViewController.swift b/passAutoFillExtension/Controllers/PasswordsViewController.swift index d7a7c0f..8101234 100644 --- a/passAutoFillExtension/Controllers/PasswordsViewController.swift +++ b/passAutoFillExtension/Controllers/PasswordsViewController.swift @@ -43,8 +43,8 @@ class PasswordsViewController: UIViewController { tableView.dataSource = dataSource } - func showPasswordsWithSuggstion(_ keywords: [String]) { - dataSource.showTableEntriesWithSuggestion(matching: keywords) + func showPasswordsWithSuggstion(matching text: String) { + dataSource.showTableEntriesWithSuggestion(matching: text) tableView.reloadData() } diff --git a/passAutoFillExtension/Services/PasswordsTableDataSource.swift b/passAutoFillExtension/Services/PasswordsTableDataSource.swift index 95851e2..b0eeadb 100644 --- a/passAutoFillExtension/Services/PasswordsTableDataSource.swift +++ b/passAutoFillExtension/Services/PasswordsTableDataSource.swift @@ -91,13 +91,9 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource { showSuggestion = false } - func showTableEntriesWithSuggestion(matching keywords: [String]) { + func showTableEntriesWithSuggestion(matching text: String) { for entry in passwordTableEntries { - var match = false - for keyword in keywords { - match = match || entry.match(keyword) - } - if match { + if entry.match(text) { suggestedPasswordsTableEntries.append(entry) } else { otherPasswordsTableEntries.append(entry)