mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-04 13:10:24 +08:00
修复IP库模板可能无法正确解析数据的问题
This commit is contained in:
@@ -38,7 +38,7 @@ func (this *Template) init() error {
|
||||
|
||||
return keyword
|
||||
})
|
||||
reg, err := regexp.Compile(template)
|
||||
reg, err := regexp.Compile("^(?U)" + template)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -23,3 +23,16 @@ func TestNewTemplate(t *testing.T) {
|
||||
t.Log(s, "=>\n", values)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewTemplate2(t *testing.T) {
|
||||
template, err := iplibrary.NewTemplate("${any},${any},${ipFrom},${ipTo},${country},${province},${city},${town},${provider},${any},${any}")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, s := range []string{
|
||||
"22723584,22723839,1.90.188.0,1.90.188.255,中国,北京,北京,房山,歌华有线,102400,010,城域网",
|
||||
} {
|
||||
values, _ := template.Extract(s, []string{})
|
||||
t.Log(s, "=>\n", values)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user