refactor: don't use a regex to check a string cache entry is a regex

This commit is contained in:
ThinkChaos 2023-02-06 20:13:41 -05:00
parent 6548d15d8b
commit 36160e916e
1 changed files with 2 additions and 4 deletions

View File

@ -179,11 +179,9 @@ type chainedCacheFactory struct {
regexCacheFactory CacheFactory
}
var regexPattern = regexp.MustCompile("^/.*/$")
func (r *chainedCacheFactory) AddEntry(entry string) {
if regexPattern.MatchString(entry) {
entry = strings.TrimSpace(strings.Trim(entry, "/"))
if strings.HasPrefix(entry, "/") && strings.HasSuffix(entry, "/") {
entry = strings.TrimSpace(entry[1 : len(entry)-1])
r.regexCacheFactory.AddEntry(entry)
} else {
r.stringCacheFactory.AddEntry(entry)