From a675e5442b7d5d0eada733a740a97e3dbaebd533 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 12 Feb 2020 21:03:04 +0100 Subject: [PATCH] link fe: make uxToHex more safe Matching implementation from contacts' lib/util.js. --- pkg/interface/link/src/js/lib/util.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/interface/link/src/js/lib/util.js b/pkg/interface/link/src/js/lib/util.js index a6420d6f2b..2180ef8234 100644 --- a/pkg/interface/link/src/js/lib/util.js +++ b/pkg/interface/link/src/js/lib/util.js @@ -128,9 +128,10 @@ export function deSig(ship) { return ship.replace('~', ''); } -//TODO look at uxToHex wonky functionality -//TODO what does "wonky functionality" refer to? export function uxToHex(ux) { - let value = ux.substr(2).replace('.', '').padStart(6, '0'); - return value; + if (ux.length > 2 && ux.substr(0,2) === '0x') { + return ux.substr(2).replace('.', '').padStart(6, '0'); + } else { + return ux.replace('.', '').padStart(6, '0'); + } }