mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 12:01:52 -07:00
Added restrictions for separators
This commit is contained in:
parent
ebe01c2d43
commit
bfbbd97324
2 changed files with 9 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ If the environment variable is defined without **and** with the suffix at the sa
|
||||||
- Description: The lowercase name of the default theme to be used by the client. Overridden if a user picks a theme in the theme switcher.
|
- Description: The lowercase name of the default theme to be used by the client. Overridden if a user picks a theme in the theme switcher.
|
||||||
##### KOITO_DATE_FORMAT
|
##### KOITO_DATE_FORMAT
|
||||||
- Default: `Browser locale`
|
- Default: `Browser locale`
|
||||||
- Description: The format to use for dates in the client. Supports the tokens `DD`, `MM`, and `YYYY` with any separator. For example, `DD/MM/YYYY` produces `21/04/2026`. When not set, dates are formatted using the browser's locale.
|
- Description: The format to use for dates in the client. Supports the tokens `DD`, `MM`, and `YYYY` with `/`, `-`, and `.`as separators. For example, `DD/MM/YYYY` produces `21/04/2026`. When not set, dates are formatted using the browser's locale.
|
||||||
##### KOITO_LOGIN_GATE
|
##### KOITO_LOGIN_GATE
|
||||||
- Default: `false`
|
- Default: `false`
|
||||||
- Description: When `true`, Koito will not show any statistics unless the user is logged in.
|
- Description: When `true`, Koito will not show any statistics unless the user is logged in.
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,14 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.defaultTheme = getenv(DEFAULT_THEME_ENV)
|
cfg.defaultTheme = getenv(DEFAULT_THEME_ENV)
|
||||||
cfg.dateFormat = getenv(DATE_FORMAT_ENV)
|
rawDateFormat := getenv(DATE_FORMAT_ENV)
|
||||||
|
if rawDateFormat != "" {
|
||||||
|
validFormat := regexp.MustCompile(`^(DD|MM|YYYY)([-/.](DD|MM|YYYY)){2}$`)
|
||||||
|
if !validFormat.MatchString(rawDateFormat) {
|
||||||
|
return nil, fmt.Errorf("loadConfig: %s must use DD, MM, and YYYY tokens with a single / - or . separator (e.g. DD/MM/YYYY)", DATE_FORMAT_ENV)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg.dateFormat = rawDateFormat
|
||||||
|
|
||||||
cfg.configDir = getenv(CONFIG_DIR_ENV)
|
cfg.configDir = getenv(CONFIG_DIR_ENV)
|
||||||
if cfg.configDir == "" {
|
if cfg.configDir == "" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue