Fix matching algorithm in AutoFill
This commit is contained in:
parent
9e8994f576
commit
571281b655
3 changed files with 6 additions and 22 deletions
|
|
@ -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: "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue