Added uuid normalization for mojang's uuid to textures request

This commit is contained in:
ErickSkrauch 2020-04-03 20:23:34 +03:00
parent 20a8d90ad7
commit bd13480175
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
2 changed files with 5 additions and 3 deletions

View File

@ -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"
}

View File

@ -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)