Skip to content

Commit 518399e

Browse files
committed
add 3 char hex color support in hexToRGB function
add input checking in hexToRGB function
1 parent 682ac82 commit 518399e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

public/js/lib/models/arrow.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {};
4343
@returns {Array}
4444
**/
4545
hexToRGB: function (h) {
46+
if ( typeof h !== 'string' || !h.match(/^#([0-9A-F]{3}$)|([0-9A-F]{6}$)/i) ) return [0, 0, 0];
47+
else if ( h.match(/^(#[0-9a-f]{3})$/i) ) h = '#' + h[1] + h[1] + h[2] + h[2] + h[3] + h[3];
4648
var rgb = [],
4749
i = 1;
4850

0 commit comments

Comments
 (0)