Skip to content

Commit

Permalink
Merge pull request #144 from FLamparski/make-valid-colours
Browse files Browse the repository at this point in the history
[fix] Ensure that colours are always of the form #RRGGBB
  • Loading branch information
Marak committed Nov 29, 2014
2 parents 0370b2e + 8e7cf7f commit 8b9ca65
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/internet.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ var internet = {
var red = Math.floor((faker.random.number(256) + baseRed255) / 2);
var green = Math.floor((faker.random.number(256) + baseRed255) / 2);
var blue = Math.floor((faker.random.number(256) + baseRed255) / 2);
return '#' + red.toString(16) + green.toString(16) + blue.toString(16);
var redStr = red.toString(16);
var greenStr = green.toString(16);
var blueStr = blue.toString(16);
return '#' +
(redStr.length === 1 ? '0' : '') + redStr +
(greenStr.length === 1 ? '0' : '') + greenStr +
(blueStr.length === 1 ? '0': '') + blueStr;

},

Expand Down

0 comments on commit 8b9ca65

Please sign in to comment.