Skip to content

Commit 8406c49

Browse files
committed
refactor: code review changes
1 parent 5c9e9f0 commit 8406c49

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/patterns/hex-color.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { buildRegExp } from '../builders';
22
import { endOfString, startOfString } from '../constructs/anchors';
33
import { charClass, charRange, digit } from '../constructs/character-class';
44
import { choiceOf } from '../constructs/choice-of';
5-
import { optional } from '../constructs/quantifiers';
65
import { repeat } from '../constructs/repeat';
76

87
const hexDigit = charClass(digit, charRange('a', 'f'));
@@ -22,19 +21,17 @@ export const hexColorFinder = buildRegExp(
2221
/**
2322
* Check that given text is a valid hex color.
2423
*
25-
* Allows both 3 and 6 digit hex colors, with or without the leading `#`.
24+
* Allows both 3 and 6 digit hex colors.
2625
* */
2726
export const hexColorValidator = buildRegExp(
2827
[
2928
startOfString, // Match whole string
30-
optional('#'),
29+
'#',
3130
choiceOf(
3231
repeat(hexDigit, 6), // #rrggbb
3332
repeat(hexDigit, 3), // #rgb
3433
),
3534
endOfString,
3635
],
37-
{
38-
ignoreCase: true,
39-
},
36+
{ ignoreCase: true },
4037
);

0 commit comments

Comments
 (0)