mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Improve duplicate checking in address book.
This commit is contained in:
parent
dc2d614da6
commit
7182a2be43
@ -39,12 +39,12 @@ class AddressBookController {
|
||||
// upper limit to the number of addresses.
|
||||
_addToAddressBook (address, name) {
|
||||
let addressBook = this._getAddressBook()
|
||||
let index = addressBook.findIndex((element) => { return element.address === address || element.name === name })
|
||||
let index = addressBook.findIndex((element) => { return element.address.toLowerCase() === address.toLowerCase() || element.name === name })
|
||||
if (index !== -1) {
|
||||
addressBook.splice(index, 1)
|
||||
}
|
||||
addressBook.push({
|
||||
address,
|
||||
address: address,
|
||||
name,
|
||||
})
|
||||
return Promise.resolve(addressBook)
|
||||
|
Loading…
Reference in New Issue
Block a user