Skip to content

Commit

Permalink
Fix favicon usesNewlines()
Browse files Browse the repository at this point in the history
  • Loading branch information
Tisawesomeness committed Sep 15, 2023
1 parent 0131c08 commit d810ba5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Optional<Favicon> parse(@NonNull String str) {
}
String imageData = str.substring(PREAMBLE.length());
boolean usesNewlines = false;
if (imageData.indexOf('\r') == -1 || imageData.indexOf('\n') == -1) {
if (imageData.indexOf('\r') != -1 || imageData.indexOf('\n') != -1) {
imageData = NEWLINES_PATTERN.matcher(imageData).replaceAll("");
usesNewlines = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public void testParse() {
Optional<Favicon> iconOpt = Favicon.parse(HYPIXEL_FAVICON);
assertThat(iconOpt).isNotEmpty();
Favicon icon = iconOpt.get();
assertThat(icon.usesNewlines()).isFalse();
assertThat(icon.validate())
.asRight(InstanceOfAssertFactories.type(Dimensions.class))
.extracting(Dimensions::getWidth, Dimensions::getHeight)
.containsExactly(Favicon.EXPECTED_SIZE, Favicon.EXPECTED_SIZE);
}
@Test
public void testParseNewline() {
Optional<Favicon> iconOpt = Favicon.parse(HYPIXEL_FAVICON + "\n");
assertThat(iconOpt).isNotEmpty();
Favicon icon = iconOpt.get();
assertThat(icon.usesNewlines()).isTrue();
assertThat(icon.validate())
.asRight(InstanceOfAssertFactories.type(Dimensions.class))
.extracting(Dimensions::getWidth, Dimensions::getHeight)
Expand Down

0 comments on commit d810ba5

Please sign in to comment.