link fe: make uxToHex more safe

Matching implementation from contacts' lib/util.js.
This commit is contained in:
Fang 2020-02-12 21:03:04 +01:00
parent 33f7d62186
commit a675e5442b
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -128,9 +128,10 @@ export function deSig(ship) {
return ship.replace('~', ''); return ship.replace('~', '');
} }
//TODO look at uxToHex wonky functionality
//TODO what does "wonky functionality" refer to?
export function uxToHex(ux) { export function uxToHex(ux) {
let value = ux.substr(2).replace('.', '').padStart(6, '0'); if (ux.length > 2 && ux.substr(0,2) === '0x') {
return value; return ux.substr(2).replace('.', '').padStart(6, '0');
} else {
return ux.replace('.', '').padStart(6, '0');
}
} }