From fe337702bd2b91f0b319eeb480c21032fef7b911 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 18 Nov 2018 23:32:43 +0800 Subject: [PATCH] Revert indent --- vendor-overwrites/colorpicker/colorconverter.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/vendor-overwrites/colorpicker/colorconverter.js b/vendor-overwrites/colorpicker/colorconverter.js index 6f1402c2..f681792c 100644 --- a/vendor-overwrites/colorpicker/colorconverter.js +++ b/vendor-overwrites/colorpicker/colorconverter.js @@ -98,15 +98,16 @@ const colorConverter = (() => { str = colorConverter.NAMED_COLORS.get(str); if (!str) return; } + if (str[0] === '#') { - if (validateHex(str)) { - str = str.slice(1); - const [r, g, b, a = 255] = str.length <= 4 ? - str.match(/(.)/g).map(c => parseInt(c + c, 16)) : - str.match(/(..)/g).map(c => parseInt(c, 16)); - return {type: 'hex', r, g, b, a: a === 255 ? undefined : a / 255}; + if (!validateHex(str)) { + return null; } - return null; + str = str.slice(1); + const [r, g, b, a = 255] = str.length <= 4 ? + str.match(/(.)/g).map(c => parseInt(c + c, 16)) : + str.match(/(..)/g).map(c => parseInt(c, 16)); + return {type: 'hex', r, g, b, a: a === 255 ? undefined : a / 255}; } const [, type, value] = str.match(/^(rgb|hsl)a?\((.*?)\)|$/i);