Fails gracefully when not passed a string.
This commit is contained in:
parent
d30a076f4b
commit
32aa02a8c2
2 changed files with 11 additions and 0 deletions
|
|
@ -126,6 +126,10 @@
|
||||||
isValid: false
|
isValid: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof data !== 'string') {
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
// Identify prefix
|
// Identify prefix
|
||||||
var trimmed = data.trim();
|
var trimmed = data.trim();
|
||||||
var colonSplit = /^([\w-]*):?(.*)$/.exec(trimmed);
|
var colonSplit = /^([\w-]*):?(.*)$/.exec(trimmed);
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,13 @@ fdescribe('bitcoinUriService', function() {
|
||||||
expect(parsed.isValid).toBe(false);
|
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() {
|
it('private key encrypted with BIP38', function() {
|
||||||
|
|
||||||
var parsed = bitcoinUriService.parse('6PRN5nEDmX842gsBzJryPu8Tw5kcsaQq1GPLcjVQPcEStvbFAtz11JX9pX');
|
var parsed = bitcoinUriService.parse('6PRN5nEDmX842gsBzJryPu8Tw5kcsaQq1GPLcjVQPcEStvbFAtz11JX9pX');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue