From bd134801759fedeec400f28ef4469c2dee41355c Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 3 Apr 2020 20:23:34 +0300 Subject: [PATCH] Added uuid normalization for mojang's uuid to textures request --- api/mojang/mojang.go | 4 +++- api/mojang/mojang_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/mojang/mojang.go b/api/mojang/mojang.go index 5e90566..7527b97 100644 --- a/api/mojang/mojang.go +++ b/api/mojang/mojang.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "strings" "time" ) @@ -86,7 +87,8 @@ func UsernamesToUuids(usernames []string) ([]*ProfileInfo, error) { // Obtains textures information for provided uuid // See https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape func UuidToTextures(uuid string, signed bool) (*SignedTexturesResponse, error) { - url := "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + normalizedUuid := strings.ReplaceAll(uuid, "-", "") + url := "https://sessionserver.mojang.com/session/minecraft/profile/" + normalizedUuid if signed { url += "?unsigned=false" } diff --git a/api/mojang/mojang_test.go b/api/mojang/mojang_test.go index 44c7a96..b2756ca 100644 --- a/api/mojang/mojang_test.go +++ b/api/mojang/mojang_test.go @@ -205,7 +205,7 @@ func TestUuidToTextures(t *testing.T) { } }) - t.Run("obtain signed textures", func(t *testing.T) { + t.Run("obtain signed textures with dashed uuid", func(t *testing.T) { assert := testify.New(t) defer gock.Off() @@ -230,7 +230,7 @@ func TestUuidToTextures(t *testing.T) { HttpClient = client - result, err := UuidToTextures("4566e69fc90748ee8d71d7ba5aa00d20", true) + result, err := UuidToTextures("4566e69f-c907-48ee-8d71-d7ba5aa00d20", true) if assert.NoError(err) { assert.Equal("4566e69fc90748ee8d71d7ba5aa00d20", result.Id) assert.Equal("Thinkofdeath", result.Name)