diff --git a/src/main/java/hudson/plugins/greenballs/GreenBallFilter.java b/src/main/java/hudson/plugins/greenballs/GreenBallFilter.java index 36e1329..cb60800 100644 --- a/src/main/java/hudson/plugins/greenballs/GreenBallFilter.java +++ b/src/main/java/hudson/plugins/greenballs/GreenBallFilter.java @@ -80,11 +80,11 @@ private String mapImage(String uri) { ColorBlindProperty colorBlindProperty = user.getProperty(ColorBlindProperty.class); if (colorBlindProperty != null && colorBlindProperty.isEnabledColorBlindSupport()) { if ((m = patternBlue.matcher(uri)).find()) { - return basePath + "colorblind" + m.group(1) + "/green" + m.group(2) + ".gif"; + return basePath + "colorblind" + "/" + m.group(1) + "/green" + m.group(2) + ".gif"; } else if ((m = patternRed.matcher(uri)).find()) { - return basePath + "colorblind" + m.group(1) + "/red" + m.group(2) + ".gif"; + return basePath + "colorblind" + "/" + m.group(1) + "/red" + m.group(2) + ".gif"; } else if ((m = patternYellow.matcher(uri)).find()) { - return basePath + "colorblind" + m.group(1) + "/yellow" + m.group(2) + ".gif"; + return basePath + "colorblind" + "/" + m.group(1) + "/yellow" + m.group(2) + ".gif"; } return null; } diff --git a/src/test/java/hudson/plugins/greenballs/GreenBallFilterTest.java b/src/test/java/hudson/plugins/greenballs/GreenBallFilterTest.java index 1c1d279..5bcc49c 100644 --- a/src/test/java/hudson/plugins/greenballs/GreenBallFilterTest.java +++ b/src/test/java/hudson/plugins/greenballs/GreenBallFilterTest.java @@ -30,6 +30,18 @@ static void patternMatchAnime(Matcher m) { assertThat(m.group(2), equalTo("_anime")); } + static void patternMatchColorblind(Matcher m) { + assertThat(m.find(), is(true)); + assertThat(m.group(1), equalTo("48x48")); + assertThat(m.group(2), equalTo("")); + } + + static void patternMatchColorblindAnime(Matcher m) { + assertThat(m.find(), is(true)); + assertThat(m.group(1), equalTo("48x48")); + assertThat(m.group(2), equalTo("_anime")); + } + @Test public void patternShouldMatch() { final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/48x48/blue.gif"); @@ -69,4 +81,24 @@ public void patternShouldNotMatch() { final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/48x48/yello_anime.gif"); assertThat(m3.find(), is(false)); } -} \ No newline at end of file + + @Test + public void patternShouldMatchColorblind() { + final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/colorblind/48x48/blue.gif"); + final Matcher m2 = GreenBallFilter.patternYellow.matcher("/nocacheImages/colorblind/48x48/yellow.gif"); + final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/colorblind/48x48/red.gif"); + patternMatchColorblind(m); + patternMatchColorblind(m2); + patternMatchColorblind(m3); + } + + @Test + public void patternShouldMatchColorblindAnime() { + final Matcher m = GreenBallFilter.patternBlue.matcher("/nocacheImages/colorblind/48x48/blue_anime.gif"); + final Matcher m2 = GreenBallFilter.patternYellow.matcher("/nocacheImages/colorblind/48x48/yellow_anime.gif"); + final Matcher m3 = GreenBallFilter.patternRed.matcher("/nocacheImages/colorblind/48x48/red_anime.gif"); + patternMatchColorblindAnime(m); + patternMatchColorblindAnime(m2); + patternMatchColorblindAnime(m3); + } +}