From 6192a58f63a69f16709964e9989fdc66410f492e Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 1 Feb 2018 22:58:34 +0300 Subject: [PATCH] Removed buildUrl() helper for automatically adding ely.by domain to skin. Now it's universtal --- http/face.go | 4 ++-- http/http.go | 9 --------- http/http_test.go | 6 ------ http/skin.go | 2 +- http/textures.go | 2 -- 5 files changed, 3 insertions(+), 20 deletions(-) diff --git a/http/face.go b/http/face.go index 2032f39..9578737 100644 --- a/http/face.go +++ b/http/face.go @@ -19,9 +19,9 @@ func (cfg *Config) Face(response http.ResponseWriter, request *http.Request) { hash = rec.Hash } - http.Redirect(response, request, buildElyUrl(buildFaceUrl(hash)), 301) + http.Redirect(response, request, buildFaceUrl(hash), 301) } func buildFaceUrl(hash string) string { - return "/minecraft/skin_buffer/faces/" + hash + ".png" + return "http://ely.by/minecraft/skin_buffer/faces/" + hash + ".png" } diff --git a/http/http.go b/http/http.go index 6213166..0020081 100644 --- a/http/http.go +++ b/http/http.go @@ -79,15 +79,6 @@ func parseUsername(username string) string { return username } -func buildElyUrl(route string) string { - prefix := "http://ely.by" - if !strings.HasPrefix(route, prefix) { - route = prefix + route - } - - return route -} - func waitForSignal() os.Signal { ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) diff --git a/http/http_test.go b/http/http_test.go index 3c58763..45fdac3 100644 --- a/http/http_test.go +++ b/http/http_test.go @@ -16,12 +16,6 @@ func TestParseUsername(t *testing.T) { assert.Equal("test", parseUsername("test"), "Function should return string itself, if it not contains .png at end") } -func TestBuildElyUrl(t *testing.T) { - assert := testify.New(t) - assert.Equal("http://ely.by/route", buildElyUrl("/route"), "Function should add prefix to the provided relative url.") - assert.Equal("http://ely.by/test/route", buildElyUrl("http://ely.by/test/route"), "Function should do not add prefix to the provided prefixed url.") -} - type mocks struct { Skins *mock_interfaces.MockSkinsRepository Capes *mock_interfaces.MockCapesRepository diff --git a/http/skin.go b/http/skin.go index 0c8e0eb..49531dc 100644 --- a/http/skin.go +++ b/http/skin.go @@ -18,7 +18,7 @@ func (cfg *Config) Skin(response http.ResponseWriter, request *http.Request) { return } - http.Redirect(response, request, buildElyUrl(rec.Url), 301) + http.Redirect(response, request, rec.Url, 301) } func (cfg *Config) SkinGET(response http.ResponseWriter, request *http.Request) { diff --git a/http/textures.go b/http/textures.go index 4001b29..aa58529 100644 --- a/http/textures.go +++ b/http/textures.go @@ -46,8 +46,6 @@ func (cfg *Config) Textures(response http.ResponseWriter, request *http.Request) skin.Url = "http://skins.minecraft.net/MinecraftSkins/" + username + ".png" skin.Hash = string(buildNonElyTexturesHash(username)) - } else { - skin.Url = buildElyUrl(skin.Url) } textures := texturesResponse{