diff --git a/pkg/ogame/utils.go b/pkg/ogame/utils.go index 3b1be8b5..307a6d87 100644 --- a/pkg/ogame/utils.go +++ b/pkg/ogame/utils.go @@ -7,6 +7,7 @@ import ( "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" "regexp" + "sort" "strings" "unicode" ) @@ -63,6 +64,20 @@ func ParseCoord(str string) (coord Coordinate, err error) { var namesChars = "ЁАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяёァイウオガキケコサザシスズソタダチッテデトドニノバパビフプヘマミムャヤラルレロンー偵列加反収器回型塔大太子察射導小履巡帶弾彈惡戦戰抗探撃收星機死残殖毀民洋滅漿炮爆發砲磁罩者能船艦衛諜護路車軌軽輕輸農送運道重間闘防陽際離雷電飛骸鬥魔" var namesRgx = regexp.MustCompile("[^a-zA-Zα-ωΑ-Ω" + namesChars + "]+") +func unique(s string) string { + //s = strings.ToLower(s) + m := make(map[rune]struct{}) + for _, c := range s { + m[c] = struct{}{} + } + arr := make([]string, 0) + for k := range m { + arr = append(arr, string(k)) + } + sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] }) + return strings.Join(arr, "") +} + // DefenceName2ID ... func DefenceName2ID(name string) ID { t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 063e66b0..6b7b7bf2 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -8,7 +8,6 @@ import ( "io/ioutil" "net/http" "regexp" - "sort" "strconv" "strings" ) @@ -114,20 +113,6 @@ func GetNbrShips(doc *goquery.Document, name string) int64 { return ParseInt(m[1]) } -func unique(s string) string { - //s = strings.ToLower(s) - m := make(map[rune]struct{}) - for _, c := range s { - m[c] = struct{}{} - } - arr := make([]string, 0) - for k := range m { - arr = append(arr, string(k)) - } - sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] }) - return strings.Join(arr, "") -} - func ReadBody(resp *http.Response) (respContent []byte, err error) { var reader io.ReadCloser switch resp.Header.Get("Content-Encoding") {