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
|
|
@ -188,7 +188,14 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
|
|||
}
|
||||
|
||||
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)
|
||||
if cfg.configDir == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue