Skip to content

Commit 547d2b5

Browse files
Update lib/util.js
Co-authored-by: Aviv Keller <me@aviv.sh>
1 parent 37ddc2a commit 547d2b5

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lib/util.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,8 @@ function replaceCloseCode(str, closeSeq, openSeq, keepClose) {
209209
return result + str.slice(lastIndex);
210210
}
211211

212-
// Matches #RGB or #RRGGBB
213-
const hexColorRegExp = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
214-
// Matches bg#RGB or bg#RRGGBB
215-
const bgHexColorRegExp = /^bg#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
212+
// Matches (fg|bg)?#RGB, (fg|bg)?#RRGGBB
213+
const hexColorRegExp = /^(bg|fg)?#([0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?)$/;
216214

217215
/**
218216
* Parses a hex color string into RGB components.

0 commit comments

Comments
 (0)