1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

clean up the isHex function

This commit is contained in:
Frankie 2016-10-21 16:05:39 -07:00
parent d4c0a4949b
commit d79424e9c0

View File

@ -212,7 +212,8 @@ 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
if (str.startsWith('0x')) {
return !str.substring(2).match(/([g-zG-Z]|\W)/)
}
return !str.match(/([g-zG-Z]|\W)/)
}