From 6f3912a5437ce4ab2225af9f7ecf8c8758642b83 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Sun, 5 Feb 2023 17:51:21 +0100 Subject: [PATCH] Use long and short gh param value for color scheme and pattern --- idicon.go | 4 ++-- idicon_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/idicon.go b/idicon.go index d180ef3..f8f6fe9 100644 --- a/idicon.go +++ b/idicon.go @@ -47,12 +47,12 @@ func requestHandler(w http.ResponseWriter, r *http.Request) { cFunc := icons.ColorV2 if colorScheme == "v1" { cFunc = icons.ColorV1 - } else if colorScheme == "gh" { + } else if colorScheme == "gh" || colorScheme == "github" { cFunc = icons.ColorGh } var iconGenerator icons.IconGenerator - if pattern == "github" { + if pattern == "github" || pattern == "gh" { iconGenerator = icons.NewGhIconGenerator().WithColorGenerator(cFunc) } else { iconGenerator = icons.NewIdIconGenerator().WithColorGenerator(cFunc) diff --git a/idicon_test.go b/idicon_test.go index 6bc3b6a..b508e76 100644 --- a/idicon_test.go +++ b/idicon_test.go @@ -85,6 +85,20 @@ func TestCorrectResponseForGHColorSchemeAndPattern(t *testing.T) { } } +func TestCorrectResponseForAltGHColorSchemeAndPattern(t *testing.T) { + req, err := http.NewRequest("GET", "/avatar/1a79a4d60de6718e8e5b326e338ae533?c=github&d=gh", nil) + if err != nil { + t.Fatal(err) + } + + rr := httptest.NewRecorder() + testRouter().ServeHTTP(rr, req) + + if !reflect.DeepEqual(rr.Body.Bytes(), gh1) { + t.Errorf("returned image does not match expected image") + } +} + func TestUsesConfig(t *testing.T) { configure("./testdata/testconfig.toml")