From 8085930dfed01923a2169ee042eec6ed27bdb6c9 Mon Sep 17 00:00:00 2001 From: Siesta <124433727+siestaw@users.noreply.github.com> Date: Thu, 18 Sep 2025 09:18:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.go):=20check=20if=20he?= =?UTF-8?q?x-code=20starts=20with=20an=20#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/internal/db/queries.go | 2 +- cmd/utils/utils.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/internal/db/queries.go b/cmd/internal/db/queries.go index 4d347ad..0fbbc18 100644 --- a/cmd/internal/db/queries.go +++ b/cmd/internal/db/queries.go @@ -104,7 +104,7 @@ func ViewColor(id int) (*models.LampState, error) { func SetColor(id int, color string) error { if !utils.IsValidHexColor(color) { - return errors.New("invalid HEX Code: %s") + return errors.New("invalid HEX Code") } currentColor, err := ViewColor(id) if err != nil { diff --git a/cmd/utils/utils.go b/cmd/utils/utils.go index f14f194..a3cd5c9 100644 --- a/cmd/utils/utils.go +++ b/cmd/utils/utils.go @@ -26,7 +26,7 @@ func IDtoInt(id string) (int, error) { } func IsValidHexColor(color string) bool { - pattern := `^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$` + pattern := `^#(?:[A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$` match, _ := regexp.MatchString(pattern, color) return match }