Skip to content

Commit

Permalink
Support empty file names in UriUtils::extractFileExtension
Browse files Browse the repository at this point in the history
Closes gh-27639
  • Loading branch information
poutsma committed Nov 19, 2021
1 parent c37d6c3 commit 722ab25
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public static String extractFileExtension(String path) {
int paramIndex = path.indexOf(';', begin);
end = (paramIndex != -1 && paramIndex < end ? paramIndex : end);
int extIndex = path.lastIndexOf('.', end);
if (extIndex != -1 && extIndex > begin) {
if (extIndex != -1 && extIndex >= begin) {
return path.substring(extIndex + 1, end);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void extractFileExtension() {
assertThat(UriUtils.extractFileExtension("/products;q=11/view.html?param=/path/a.do")).isEqualTo("html");
assertThat(UriUtils.extractFileExtension("/products;q=11/view.html;r=22?param=/path/a.do")).isEqualTo("html");
assertThat(UriUtils.extractFileExtension("/products;q=11/view.html;r=22;s=33?param=/path/a.do")).isEqualTo("html");
assertThat(UriUtils.extractFileExtension("/products/.html")).isEqualTo("html");
}

}

0 comments on commit 722ab25

Please sign in to comment.