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

This commit is contained in:
刘祥超
2023-03-09 12:10:31 +08:00
parent f4a690a5c3
commit c73a05eceb
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
}