diff --git a/js/models/contact_model.js b/js/models/contact_model.js index 3a613a268..cc2579fc4 100644 --- a/js/models/contact_model.js +++ b/js/models/contact_model.js @@ -159,9 +159,17 @@ angular.module('contactsApp') var matchingProps = ['fn', 'title', 'org', 'email', 'nickname', 'note', 'url', 'cloud', 'adr', 'impp', 'tel'].filter(function (propName) { if (model.props[propName]) { return model.props[propName].filter(function (property) { - if (property.value && _.isString(property.value)) { + if (!property.value) { + return false; + } + if (_.isString(property.value)) { return property.value.toLowerCase().indexOf(pattern.toLowerCase()) !== -1; } + if (_.isArray(property.value)) { + return property.value.filter(function(v) { + return v.toLowerCase().indexOf(pattern.toLowerCase()) !== -1; + }).length > 0; + } return false; }).length > 0; } diff --git a/js/tests/models/contact_model.js b/js/tests/models/contact_model.js index 9cc32a8f9..982eb7b5c 100644 --- a/js/tests/models/contact_model.js +++ b/js/tests/models/contact_model.js @@ -14,4 +14,11 @@ describe('contactModel', function() { expect(contact.matches('the')).to.equal(true); expect(contact.matches('OSS')).to.equal(true); }); + + it('should match a search pattern in address', function() { + var contact = new $Contact({displayName: 'test'}); + contact.setProperty('adr', {value: ["12", "", "", "Kenya", "", "", ""]}); + expect(contact.matches('12')).to.equal(true); + expect(contact.matches('kenya')).to.equal(true); + }); });