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

add trim for result

This commit is contained in:
zu1k 2020-07-21 17:54:57 +08:00
parent e69316b95d
commit ace8309f64
2 changed files with 8 additions and 5 deletions

View File

@ -66,7 +66,7 @@ Find document on: https://github.com/zu1k/nali
if line == "quit" || line == "exit" {
return
}
fmt.Println(app.ReplaceIPInString(app.ReplaceCDNInString(line)))
fmt.Printf("%s\n", app.ReplaceIPInString(app.ReplaceCDNInString(line)))
}
} else {
app.ParseIPs(args)

View File

@ -1,12 +1,15 @@
package tools
import "strings"
import (
"strings"
)
func ReplaceAdd(origin string, old string, new string) string {
func ReplaceAdd(origin string, old string, new string) (result string) {
subLen := len(new) - len(old)
wanted := old + strings.Repeat(" ", subLen)
if strings.Contains(origin, wanted) {
return strings.ReplaceAll(origin, wanted, new)
result = strings.ReplaceAll(origin, wanted, new)
}
return strings.ReplaceAll(origin, old, new)
result = strings.ReplaceAll(origin, old, new)
return strings.TrimRight(result, " \t")
}