Skip to content

Commit c425e20

Browse files
tswatersCharlike Mike Reagent
authored andcommitted
fix: make it work with percentages, closes #1
Fixes #1 Also need to update CI because mocha doesn't run on oldnode anymore 😄
1 parent 1818b61 commit c425e20

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- 'iojs'
5-
- '0.12'
6-
- '0.10'
4+
- '6'
5+
- '8'

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ module.exports = function rgbaRegex(options) {
44
options = options || {};
55

66
return options.exact ?
7-
/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/ :
8-
/rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)/ig;
7+
/^rgba\((\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d*(?:\.\d+)?)\)$/ :
8+
/rgba\((\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d*(?:\.\d+)?)\)/ig;
99
}

test/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ var assert = require('assert');
22
var rgbaRegex = require('..');
33

44
var rgbaStrings = [
5+
'rgba(50%, 50%, 50%, 1)',
56
'rgba(12,34,56, 1)',
67
'rgba(255, 255, 255, .9)',
78
'rgba(1, 1,1, 0.2)'
89
];
910

1011
var inexactRgbaStrings = [
1112
'rgba(,,,)',
13+
'rgba(%, %, %, 1)',
1214
'rGba(12,34,56,1)',
1315
'rgba(12, 34, 200,1) ',
1416
' rgba(12,34,56,1)',

0 commit comments

Comments
 (0)