This commit is contained in:
looly 2021-12-17 17:51:36 +08:00
parent 5ba04ced6a
commit 8c7106d7f3
3 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,7 @@
* 【core 】 修复4位bytes转换float问题issue#I4M0E4@Gitee
* 【core 】 修复CharSequenceUtil.replace问题issue#I4M16G@Gitee
* 【json 】 修复JSONObject 初始化大小值未被使用问题issue#2016@Github
* 【core 】 修复StrUtil.startWith都为null返回错误问题issue#I4MV7Q@Gitee
-------------------------------------------------------------------------------------------------------------
# 5.7.17 (2021-12-09)

View File

@ -706,7 +706,7 @@ public class CharSequenceUtil {
*/
public static boolean startWith(CharSequence str, CharSequence prefix, boolean ignoreCase, boolean ignoreEquals) {
if (null == str || null == prefix) {
if (false == ignoreEquals) {
if (ignoreEquals) {
return false;
}
return null == str && null == prefix;

View File

@ -86,4 +86,11 @@ public class CharSequenceUtilTest {
v = CharSequenceUtil.subPreGbk(s, 40, true);
Assert.assertEquals(41, v.getBytes(CharsetUtil.CHARSET_GBK).length);
}
@Test
public void startWithTest(){
// https://gitee.com/dromara/hutool/issues/I4MV7Q
Assert.assertFalse(CharSequenceUtil.startWith("123", "123", false, true));
Assert.assertFalse(CharSequenceUtil.startWith(null, null, false, true));
}
}