From f1a5d1b7c57e53dac4309fc4f1d57086b42d3ee8 Mon Sep 17 00:00:00 2001 From: Artyom Belousov Date: Sat, 19 Oct 2019 23:05:57 +0300 Subject: [PATCH] Added Russian-language specific optimization --- cardsinfo/names.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cardsinfo/names.go b/cardsinfo/names.go index 65aa135..9181d2a 100644 --- a/cardsinfo/names.go +++ b/cardsinfo/names.go @@ -12,17 +12,26 @@ const SCRYFALL_URL = "https://api.scryfall.com" func GetNameByCardId(set string, number string) string { /* - Note: number is string because some cards contain letters in their numbers. + Note: number is string because some cards contain letters in their numbers. */ path := SCRYFALL_URL + "/cards/" + strings.ToLower(set) + "/" + number return GetCardByUrl(path) } func GetOriginalName(name string) string { - path := SCRYFALL_URL + "/cards/named?fuzzy=" + url.QueryEscape(name) + path := SCRYFALL_URL + "/cards/named?fuzzy=" + ApplyFilters(name) return GetCardByUrl(path) } +func ApplyFilters(name string) string { + /* + Despite of the rules of Russian language, letter ё is replaced with e on cards + Sometimes it leads to wrong search results + */ + name = strings.ReplaceAll(name, "ё", "е") + return url.QueryEscape(name) +} + func GetCardByUrl(path string) string { response, err := http.Get(path) if err != nil {