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

@@ -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));
}
}