re-organized pattern matching code

This commit is contained in:
2022-10-25 18:34:28 +02:00
parent 417faf3ff2
commit 066ddd0d98
8 changed files with 90 additions and 43 deletions

View File

@@ -186,14 +186,15 @@ func (c *Config) ApplyDefaults() {
}
}
func (c *Config) PreparePattern() error {
PatternR, err := regexp.Compile(c.Pattern)
func (c *Config) PreparePattern(pattern string) error {
PatternR, err := regexp.Compile(pattern)
if err != nil {
return errors.Unwrap(fmt.Errorf("Regexp pattern %s is invalid: %w", c.Pattern, err))
}
c.PatternR = PatternR
c.Pattern = pattern
return nil
}