1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00

fix muti replace

This commit is contained in:
zu1k 2020-07-18 14:26:22 +08:00
parent 1c9c9107d1
commit 7d8ff9a26c

View File

@ -47,12 +47,18 @@ func find(cname string) string {
}
func ReplaceCDNInString(str string) (result string) {
done := make(map[string]bool)
cnames := domainRe.FindAllString(str, -1)
result = str
for _, cname := range cnames {
name := find(cname)
if name != "未找到" && name != "无法解析" {
if _, found := done[cname]; found {
continue
}
result = strings.ReplaceAll(result, cname, fmt.Sprintf("%s [%s]", cname, name))
done[cname] = true
}
}
return