hsluv/hsluv-javascript

Converting hex to rgb assumes a 6-digit hex

Closed this issue · 1 comments

The method .hexToHsluv() assumes that the hex provided is 6 digits, eg #ff0000. However, hex colors can be 3 digits, where each digit is replicated to get the 6-digit value; eg #f00 becomes #ff0000.1

A simple fix would be to check if the hex provided is 3 digits and converting if so.

Footnotes

  1. https://www.w3.org/TR/css-color-3/#numerical

I'd rather not support this, it's not useful enough to warrant extra code