1
0
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:
Kevin Serrano 2017-03-10 10:05:10 -08:00
parent dc2d614da6
commit 7182a2be43

View File

@ -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)