We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1df239b commit dba50fdCopy full SHA for dba50fd
lib_src/misc/colors.ts
@@ -35,8 +35,15 @@ function rgb2hex(rgb: string): string {
35
if (rgb.search("rgb") === -1) {
36
return rgb
37
} else {
38
- rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/)
39
- return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
+ const rgb_match = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/)
+
40
+ if (rgb_match) {
41
+ return hex(rgb_match[1]) + hex(rgb_match[2]) + hex(rgb_match[3])
42
+ } else {
43
+ // TODO should we check for this error?
44
+ console.error(rgb.concat(" isn't a rgb string!"))
45
+ return "#000000" // black
46
+ }
47
}
48
49
0 commit comments