Skip to content

Commit

Permalink
Merge pull request #524 from aho-emi/v6
Browse files Browse the repository at this point in the history
fixed isValidHex to properly support #hex only
  • Loading branch information
baka-aho authored Dec 17, 2023
2 parents 1eb2c81 + ed4a730 commit d30df9a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/functions/util/isValidHex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module.exports = d => {
if (data.err) return d.error(data.err);

let [hex] = data.inside.splits;
hex = hex.addBrackets().replace('#', '');

data.result = isNaN(parseInt(hex, 16)) ? false : true;
const regex = /^#?([0-9A-Fa-f]{3}){1,2}$/;
data.result = regex.test(hex)

return {
code: d.util.setCode(data)
}
}
}

0 comments on commit d30df9a

Please sign in to comment.