Fails gracefully when not passed a string.

This commit is contained in:
Brendon Duncan 2018-08-29 10:15:03 +12:00
commit 32aa02a8c2
2 changed files with 11 additions and 0 deletions

View file

@ -126,6 +126,10 @@
isValid: false
};
if (typeof data !== 'string') {
return parsed;
}
// Identify prefix
var trimmed = data.trim();
var colonSplit = /^([\w-]*):?(.*)$/.exec(trimmed);

View file

@ -293,6 +293,13 @@ fdescribe('bitcoinUriService', function() {
expect(parsed.isValid).toBe(false);
});
it('non-string', function() {
var parsed = bitcoinUriService.parse([1, 2, 3, 4]);
expect(parsed.isValid).toBe(false);
});
it('private key encrypted with BIP38', function() {
var parsed = bitcoinUriService.parse('6PRN5nEDmX842gsBzJryPu8Tw5kcsaQq1GPLcjVQPcEStvbFAtz11JX9pX');