EncodeUtils.encodeUrl 忽略字符编码传递空值,默认 UTF-8

This commit is contained in:
thinkgem
2025-03-27 14:14:31 +08:00
parent 54656cb441
commit 11524982e5

View File

@@ -154,7 +154,7 @@ public class EncodeUtils {
return null;
}
try {
return URLEncoder.encode(part, encoding);
return URLEncoder.encode(part, StringUtils.isNotBlank(encoding) ? encoding : EncodeUtils.UTF_8);
} catch (UnsupportedEncodingException e) {
throw ExceptionUtils.unchecked(e);
}
@@ -175,7 +175,7 @@ public class EncodeUtils {
return null;
}
try {
return URLDecoder.decode(part, encoding);
return URLDecoder.decode(part, StringUtils.isNotBlank(encoding) ? encoding : EncodeUtils.UTF_8);
} catch (UnsupportedEncodingException e) {
throw ExceptionUtils.unchecked(e);
}