mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
fix: accept misspelled KOITO_ARTIST_SEPERATORS_REGEX env var
Accept common misspelling 'SEPERATORS' as an alias for 'SEPARATORS' in the KOITO_ARTIST_SEPARATORS_REGEX environment variable. The correct spelling takes precedence if both are set. Fixes #161
This commit is contained in:
parent
1a8099e902
commit
79618cc38d
1 changed files with 7 additions and 2 deletions
|
|
@ -47,6 +47,7 @@ const (
|
|||
IMPORT_AFTER_UNIX_ENV = "KOITO_IMPORT_AFTER_UNIX"
|
||||
FETCH_IMAGES_DURING_IMPORT_ENV = "KOITO_FETCH_IMAGES_DURING_IMPORT"
|
||||
ARTIST_SEPARATORS_ENV = "KOITO_ARTIST_SEPARATORS_REGEX"
|
||||
ARTIST_SEPARATORS_TYPO_ENV = "KOITO_ARTIST_SEPERATORS_REGEX" // common misspelling
|
||||
LOGIN_GATE_ENV = "KOITO_LOGIN_GATE"
|
||||
)
|
||||
|
||||
|
|
@ -194,8 +195,12 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
|
|||
rawCors := getenv(CORS_ORIGINS_ENV)
|
||||
cfg.allowedOrigins = strings.Split(rawCors, ",")
|
||||
|
||||
if getenv(ARTIST_SEPARATORS_ENV) != "" {
|
||||
for pattern := range strings.SplitSeq(getenv(ARTIST_SEPARATORS_ENV), ";;") {
|
||||
artistSepEnv := getenv(ARTIST_SEPARATORS_ENV)
|
||||
if artistSepEnv == "" {
|
||||
artistSepEnv = getenv(ARTIST_SEPARATORS_TYPO_ENV) // accept common misspelling
|
||||
}
|
||||
if artistSepEnv != "" {
|
||||
for pattern := range strings.SplitSeq(artistSepEnv, ";;") {
|
||||
regex, err := regexp.Compile(pattern)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile regex pattern %s", pattern)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue