mirror of
https://github.com/zu1k/nali.git
synced 2025-01-23 05:39:03 +08:00
fix muti replace
This commit is contained in:
parent
1c9c9107d1
commit
7d8ff9a26c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user