mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add test and ability for isHex to handle hex strings with hex-prefix
This commit is contained in:
parent
ac7dca22c3
commit
aa4746f4c7
@ -243,6 +243,11 @@ describe('util', function() {
|
||||
assert.equal(result, false)
|
||||
})
|
||||
|
||||
it('should return true when given a hex string with hex-prefix', function() {
|
||||
var result = util.isHex('0xc3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2')
|
||||
assert.equal(result, true)
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -212,6 +212,7 @@ function readableDate (ms) {
|
||||
}
|
||||
|
||||
function isHex (str) {
|
||||
if (str.startsWith('0x')) str = str.replace('0x', '')
|
||||
if (str.match(/[g-zG-Z]/) || str.match(/\W/)) return false
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user