Skip to content

Commit

Permalink
Fix findUrlSuffix NPE when upgrading from old version (#94)
Browse files Browse the repository at this point in the history
fixes #93
```release-note
修复从旧版本升级后上传文件的NPE错误
```
/kind bug
  • Loading branch information
longjuan authored Oct 27, 2023
1 parent c0fb2b1 commit 565d3cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/run/halo/s3os/UrlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static String removeHttpPrefix(String url) {

public static String findUrlSuffix(List<S3OsProperties.urlSuffixItem> urlSuffixList,
String fileName) {
if (StringUtils.isBlank(fileName)) {
if (StringUtils.isBlank(fileName) || urlSuffixList == null) {
return null;
}
fileName = fileName.toLowerCase();
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/run/halo/s3os/UrlUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ public void testFindUrlSuffix() {
String fileName5 = "";
String result5 = UrlUtils.findUrlSuffix(urlSuffixList, fileName5);
assertNull(result5);

// 测试urlSuffixList为null,期望返回null
String fileName6 = "example";
String result6 = UrlUtils.findUrlSuffix(null, fileName6);
assertNull(result6);
}
}

0 comments on commit 565d3cf

Please sign in to comment.