diff --git a/lib/address.js b/lib/address.js index b248aed..b3b36f3 100644 --- a/lib/address.js +++ b/lib/address.js @@ -11,7 +11,11 @@ function Address(obj) { }; Address.isValid = function(addrstr) { - var address = new Address().fromString(addrstr); + try { + var address = new Address().fromString(addrstr); + } catch (e) { + return false; + } return address.isValid(); }; diff --git a/test/test.address.js b/test/test.address.js index 0700e30..e18cf49 100644 --- a/test/test.address.js +++ b/test/test.address.js @@ -18,6 +18,10 @@ describe('Address', function() { Address.isValid(str).should.equal(true); }); + it('should invalidate this valid address string', function() { + Address.isValid(str.substr(1)).should.equal(false); + }); + }); describe('#fromPubkey', function() {