/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/clean/color.go
25 строк
464 B
Michael Mayer
Pkg: Apply "golangci-lint" recommendation to clean package #5330
21 ноя 2025, 17:28
21 ноя 2025, 17:28
23529d0
Код
Авторство
О чём код?
package clean import ( "strings" ) // Color sanitizes HTML color codes and returns them in lowercase if they are valid, or an empty string otherwise. func Color(s string) string { s = strings.ToLower(s) // Remove unwanted characters. s = strings.Map(func(r rune) rune { if (r < '0' || r > '9') && (r < 'a' || r > 'f') && r != '#' { return -1 } return r }, s) // Invalid? if l := len(s); l != 4 && l != 7 && l != 9 { return "" } return s }