Skip to content

Commit

Permalink
统一替换ipv6分割符为空格
Browse files Browse the repository at this point in the history
  • Loading branch information
fcwys committed Jul 11, 2024
1 parent 6c9b5a7 commit 999c0dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/ip2region/ip2region.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ip2region
import (
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"strings"
Expand Down Expand Up @@ -39,7 +39,7 @@ func NewIp2Region(filePath string) (*Ip2Region, error) {
}
defer f.Close()

data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return nil, err
}
Expand All @@ -56,9 +56,9 @@ func NewIp2Region(filePath string) (*Ip2Region, error) {
func (db Ip2Region) Find(query string, params ...string) (result fmt.Stringer, err error) {
if db.seacher != nil {
res, err := db.seacher.SearchByStr(query)
res = strings.ReplaceAll(res, "|", " ") //替换分割符为空格
res = strings.ReplaceAll(res, "\t", " ") //替换制表符为空格
res = strings.ReplaceAll(res, "–", " ") //替换纯真分隔符为空格
res = strings.ReplaceAll(res, "|", " ") //替换分割符为空格
res = strings.ReplaceAll(res, "\t", " ") //替换制表符为空格
res = strings.ReplaceAll(res, "–", " ") //替换纯真分隔符为空格
if err != nil {
return nil, err
} else {
Expand Down
2 changes: 2 additions & 0 deletions pkg/zxipv6wry/zxipv6wry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net"
"os"
"strings"

"github.com/zu1k/nali/pkg/wry"
)
Expand Down Expand Up @@ -79,6 +80,7 @@ func (db *ZXwry) Find(query string, _ ...string) (result fmt.Stringer, err error
offset := db.SearchIndexV6(ipu64)
reader := wry.NewReader(db.Data)
reader.Parse(offset)
reader.Result.Country = strings.ReplaceAll(reader.Result.Country, "\t", " ")
return reader.Result, nil
}

Expand Down

0 comments on commit 999c0dd

Please sign in to comment.