spatie / color

A little library to deal with color conversions
https://spatie.be/opensource/php
MIT License
350 stars 36 forks source link

Fix RegEx for Rgba() validation for alpha #70

Closed jcogs-design closed 2 years ago

jcogs-design commented 2 years ago

Current regex for Rgba() validation rejects values where the alpha value does not begin with a zero or 1, so "rgba(30,40,50,.75)" is considered invalid. It is unclear if the leading zero is a required element for the alpha value, but at least one substantive source MDN suggests not. This small change to the regex makes the leading zero of the alpha value optional, fixing this.

freekmurze commented 2 years ago

Could you add a test that demonstrates that this code is correct?

jcogs-design commented 2 years ago

Added a candidate test - not super good at writing tests so would be sensible that someone who is checks it ...

freekmurze commented 2 years ago

Add these changes to #73