增加CC防护相关API定义、配置

This commit is contained in:
GoEdgeLab
2023-03-09 12:10:31 +08:00
parent 0145758e70
commit 0e49f880e1
7 changed files with 647 additions and 306 deletions

View File

@@ -34,7 +34,11 @@ func (this *URLPattern) Init() error {
for index, piece := range pieces {
pieces[index] = regexp.QuoteMeta(piece)
}
reg, err := regexp.Compile("(?i)" /** 大小写不敏感 **/ + "^" + strings.Join(pieces, "(.*)") + "$")
var pattern = strings.Join(pieces, "(.*)")
if len(pattern) > 0 && pattern[0] == '/' {
pattern = "(http|https)://[\\w.-]+" + pattern
}
reg, err := regexp.Compile("(?i)" /** 大小写不敏感 **/ + "^" + pattern + "$")
if err != nil {
return err
}