Change how UsesRegex is determined

This commit is contained in:
Alex Tan 2021-07-10 00:54:07 -05:00
parent ece4a91ec3
commit 06466faa87

View file

@ -27,13 +27,13 @@ type HeaderConfig struct {
} }
func (config *HeaderConfig) Init() { func (config *HeaderConfig) Init() {
if config.UsesRegex() { if len(config.Regex) > 0 {
config.CompiledRegex = regexp.MustCompile(config.Regex) config.CompiledRegex = regexp.MustCompile(config.Regex)
} }
} }
func (config *HeaderConfig) UsesRegex() bool { func (config *HeaderConfig) UsesRegex() bool {
return len(config.Regex) > 0 return config.CompiledRegex != nil
} }
// HeaderDefiniton is a key value pair of a specified header rule // HeaderDefiniton is a key value pair of a specified header rule