color-string 1.7.4 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +4 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -50,9 +50,9 @@ cs.get.rgb = function (string) {
50
50
 
51
51
  var abbr = /^#([a-f0-9]{3,4})$/i;
52
52
  var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
53
- var rgba = /^rgba?\(\s*([+-]?\d+)\s*,?\s*([+-]?\d+)\s*,?\s*([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
53
+ var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
54
54
  var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
55
- var keyword = /(\w+)/;
55
+ var keyword = /^(\w+)$/;
56
56
 
57
57
  var rgb = [0, 0, 0, 1];
58
58
  var match;
@@ -90,7 +90,7 @@ cs.get.rgb = function (string) {
90
90
 
91
91
  if (match[4]) {
92
92
  if (match[5]) {
93
- rgb[3] = parseInt(match[4], 0) * 0.01;
93
+ rgb[3] = parseFloat(match[4]) * 0.01;
94
94
  } else {
95
95
  rgb[3] = parseFloat(match[4]);
96
96
  }
@@ -102,7 +102,7 @@ cs.get.rgb = function (string) {
102
102
 
103
103
  if (match[4]) {
104
104
  if (match[5]) {
105
- rgb[3] = parseInt(match[4], 0) * 0.01;
105
+ rgb[3] = parseFloat(match[4]) * 0.01;
106
106
  } else {
107
107
  rgb[3] = parseFloat(match[4]);
108
108
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "color-string",
3
3
  "description": "Parser and generator for CSS color strings",
4
- "version": "1.7.4",
4
+ "version": "1.8.2",
5
5
  "author": "Heather Arthur <fayearthur@gmail.com>",
6
6
  "contributors": [
7
7
  "Maxime Thirouin",