mirror of
https://github.com/anotherhadi/proton-vpn-tui.git
synced 2026-10-05 19:28:28 +02:00
init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package backend
|
||||
|
||||
import "strings"
|
||||
|
||||
func countryCodeFromServerId(id string) string {
|
||||
if i := strings.IndexAny(id, "-#"); i != -1 {
|
||||
return id[:i]
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func FlagEmoji(countryCode string) string {
|
||||
code := strings.ToUpper(countryCode)
|
||||
if code == "UK" {
|
||||
code = "GB"
|
||||
}
|
||||
if len(code) != 2 {
|
||||
return "🏳️"
|
||||
}
|
||||
|
||||
var flag strings.Builder
|
||||
for _, r := range code {
|
||||
if r < 'A' || r > 'Z' {
|
||||
return "🏳️"
|
||||
}
|
||||
flag.WriteRune(r + 127397)
|
||||
}
|
||||
|
||||
return flag.String()
|
||||
}
|
||||
|
||||
func FlagEmojiFromServerId(serverId string) string {
|
||||
return FlagEmoji(countryCodeFromServerId(serverId))
|
||||
}
|
||||
Reference in New Issue
Block a user