mirror of
https://github.com/zu1k/nali.git
synced 2025-01-22 21:29:02 +08:00
add trim for result
This commit is contained in:
parent
e69316b95d
commit
ace8309f64
@ -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)
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user