Skip to content

Commit 02435da

Browse files
levymetalbhough
authored andcommitted
docs(parsetorgb): update regexes
1 parent b928cdb commit 02435da

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/assets/polished.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,10 +2296,10 @@
22962296
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
22972297
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
22982298
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
2299-
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
2300-
var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
2301-
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
2302-
var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
2299+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
2300+
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
2301+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
2302+
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
23032303
/**
23042304
* Returns an RgbColor or RgbaColor object. This utility function is only useful
23052305
* if want to extract a color component. With the color util `toColorString` you
@@ -2373,7 +2373,7 @@
23732373
red: parseInt("" + rgbaMatched[1], 10),
23742374
green: parseInt("" + rgbaMatched[2], 10),
23752375
blue: parseInt("" + rgbaMatched[3], 10),
2376-
alpha: parseFloat("" + rgbaMatched[4])
2376+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
23772377
};
23782378
}
23792379

@@ -2418,7 +2418,7 @@
24182418
red: parseInt("" + _hslRgbMatched[1], 10),
24192419
green: parseInt("" + _hslRgbMatched[2], 10),
24202420
blue: parseInt("" + _hslRgbMatched[3], 10),
2421-
alpha: parseFloat("" + hslaMatched[4])
2421+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
24222422
};
24232423
}
24242424

0 commit comments

Comments
 (0)