Skip to content

Commit a1932a5

Browse files
committed
Allow for both hexcolors with alpha as shorthand
1 parent cc35690 commit a1932a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

webapp/src/Utils/Utils.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ public static function timeStringDiff(string $time1, string $time2): string
290290
*/
291291
public static function convertToHex(string $color): ?string
292292
{
293-
if (preg_match('/^#[[:xdigit:]]{3,6}$/', $color)) {
293+
if (preg_match('/^#[[:xdigit:]]{3,4}$/', $color) ||
294+
preg_match('/^#[[:xdigit:]]{6}$/', $color) ||
295+
preg_match('/^#[[:xdigit:]]{8}$/', $color)
296+
) {
294297
return $color;
295298
}
296299

0 commit comments

Comments
 (0)