Skip to content

Commit

Permalink
fix: use util isValidHex
Browse files Browse the repository at this point in the history
  • Loading branch information
zackarydev authored and mojoaxel committed Dec 19, 2019
1 parent 964eb84 commit 1b616af
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/graph3d/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,8 @@ function setSurfaceColor(surfaceColors, dst) {
let rgbColors = [];

if(Array.isArray(surfaceColors)) {
// https://stackoverflow.com/questions/8027423/how-to-check-if-a-string-is-a-valid-hex-color-representation/8027444
const hexTestRegex = /^#([0-9A-F]{3}){1,2}$/i;
rgbColors = surfaceColors.map(function(colorCode){
if(!hexTestRegex.test(colorCode)) {
if(!util.isValidHex(colorCode)) {
throw new Error('Invalid hex color code supplied to surfaceColors.');
}
return util.hexToRGB(colorCode);
Expand Down

0 comments on commit 1b616af

Please sign in to comment.