Only validate URL if type is url
This commit is contained in:
parent
2315b0bb70
commit
c708c17177
30
config.go
30
config.go
@ -27,20 +27,22 @@ func NewConfig(actionType string, actionData string) *Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *Config) Validate() {
|
func (config *Config) Validate() {
|
||||||
// Parse URL in config
|
if config.ActionType == "url" {
|
||||||
urlParser, err := url.Parse(config.ActionData)
|
// Parse URL in config
|
||||||
// If there was an error parsing
|
urlParser, err := url.Parse(config.ActionData)
|
||||||
if err != nil {
|
// If there was an error parsing
|
||||||
// Alert user of invalid url
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Invalid URL")
|
// Alert user of invalid url
|
||||||
// If scheme is not detected
|
log.Fatal().Err(err).Msg("Invalid URL")
|
||||||
} else if urlParser.Scheme == "" {
|
// If scheme is not detected
|
||||||
// Alert user of invalid scheme
|
} else if urlParser.Scheme == "" {
|
||||||
log.Fatal().Msg("Invalid URL scheme")
|
// Alert user of invalid scheme
|
||||||
// If host is not detected
|
log.Fatal().Msg("Invalid URL scheme")
|
||||||
} else if urlParser.Host == "" {
|
// If host is not detected
|
||||||
// Alert user of invalid host
|
} else if urlParser.Host == "" {
|
||||||
log.Fatal().Msg("Invalid URL host")
|
// Alert user of invalid host
|
||||||
|
log.Fatal().Msg("Invalid URL host")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user