Skip to content

Commit 9749822

Browse files
jeoychristian-bromann
authored andcommitted
fix: support multiple decimal places
1 parent ed5b661 commit 9749822

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var rgb2hex = module.exports = function rgb2hex(color) {
2828
/**
2929
* parse input
3030
*/
31-
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,3})))??\)/.exec(strippedColor);
31+
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(strippedColor);
3232

3333
if(!digits) {
3434
// or throw error if input isn't a valid rgb(a) color

rgb2hex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* parse input
2323
*/
24-
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,3})))??\)/.exec(strippedColor);
24+
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(strippedColor);
2525

2626
if(!digits) {
2727
// or throw error if input isn't a valid rgb(a) color

rgb2hex.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/rgb2hex.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ describe('rgb2hex should', () => {
6767
expect(parsedValue.alpha).toEqual(1)
6868
})
6969

70-
it('converting rgba(12,173,22,.67)', () => {
71-
const input = 'rgba(12,173,22,.67)'
70+
it('converting rgba(12,173,22,.67313)', () => {
71+
const input = 'rgba(12,173,22,.67313)'
7272
const parsedValue = rgb2hex(input)
7373

7474
expect(parsedValue).toHaveProperty('hex')

0 commit comments

Comments
 (0)