mirror of https://github.com/0xERR0R/blocky.git
refactor: don't use a regex to check a string cache entry is a regex
This commit is contained in:
parent
6548d15d8b
commit
36160e916e
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue