Skip to content

Commit 1a09208

Browse files
evilebottnawishellscape
authored andcommitted
fix: hexadecimal notation with 4 characters (#44)
1 parent 99b4192 commit 1a09208

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ module.exports = class Parser {
463463

464464
if (node.constructor.name === 'Word') {
465465
node.isHex = /^#(.+)/.test(value);
466-
node.isColor = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(value);
466+
node.isColor = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(value);
467467
}
468468
else {
469469
this.cache.push(this.current);

test/word.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ describe('Parser → Word', () => {
7070
},
7171
{
7272
it: 'should parse hex colors',
73-
test: '#123 #abcdef #a2b3c4d5',
73+
test: '#123 #f09f #abcdef #a2b3c4d5',
7474
expected: [
7575
{ type: 'word', value: '#123', isHex: true, isColor: true },
76+
{ type: 'word', value: '#f09f', isHex: true, isColor: true },
7677
{ type: 'word', value: '#abcdef', isHex: true, isColor: true },
7778
{ type: 'word', value: '#a2b3c4d5', isHex: true, isColor: true }
7879
]

0 commit comments

Comments
 (0)