Make converting string to simple icon url reusable

This commit is contained in:
Svilen Markov
2024-05-30 22:08:33 +01:00
parent 9c69509a19
commit b63b5eb262
2 changed files with 14 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import (
"os"
"regexp"
"strconv"
"strings"
"time"
"gopkg.in/yaml.v3"
@ -150,3 +151,14 @@ func (f *OptionalEnvString) UnmarshalYAML(node *yaml.Node) error {
return nil
}
func toSimpleIconIfPrefixed(icon string) (string, bool) {
if !strings.HasPrefix(icon, "si:") {
return icon, false
}
icon = strings.TrimPrefix(icon, "si:")
icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + icon + ".svg"
return icon, true
}