mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix bug
This commit is contained in:
parent
513fb1c861
commit
bf65fa3c5f
@ -23,6 +23,7 @@
|
||||
* 【core 】 修复URLBuilder中请求参数有`&`导致的问题(issue#850@Github)
|
||||
* 【core 】 修复URLBuilder中路径以`/`结尾导致的问题(issue#I1G44J@Gitee)
|
||||
* 【db 】 修复SqlBuilder中orderBy无效问题(issue#856@Github)
|
||||
* 【core 】 修复StrUtil.subBetweenAll错误问题(issue#861@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1510,7 +1510,7 @@ public class StrUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 切分字符串
|
||||
* 切分字符串,如果分隔符不存在则返回原字符串
|
||||
*
|
||||
* @param str 被切分的字符串
|
||||
* @param separator 分隔符
|
||||
@ -1976,11 +1976,14 @@ public class StrUtil {
|
||||
* @since 5.2.5
|
||||
*/
|
||||
public static String[] subBetweenAll(CharSequence str, CharSequence prefix, CharSequence suffix) {
|
||||
if (hasEmpty(str, prefix, suffix)) {
|
||||
if (hasEmpty(str, prefix, suffix) ||
|
||||
// 不包含起始字符串,则肯定没有子串
|
||||
false == contains(str, prefix)) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
final List<String> result = new LinkedList<>();
|
||||
final String[] split = split(str, prefix);
|
||||
for (String fragment : split(str, prefix)) {
|
||||
int suffixIndex = fragment.indexOf(suffix.toString());
|
||||
if (suffixIndex > 0) {
|
||||
|
@ -432,5 +432,18 @@ public class StrUtilTest {
|
||||
Assert.assertArrayEquals(new String[0], StrUtil.subBetweenAll("abc",null,"z"));
|
||||
Assert.assertArrayEquals(new String[0], StrUtil.subBetweenAll("abc","y",null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subBetweenAllTest2() {
|
||||
//issue#861@Github,起始不匹配的时候,应该直接空
|
||||
String src1 = "/* \n* hutool */ asdas /* \n* hutool */";
|
||||
String src2 = "/ * hutool */ asdas / * hutool */";
|
||||
|
||||
String[] results1 = StrUtil.subBetweenAll(src1,"/**","*/");
|
||||
Assert.assertEquals(0, results1.length);
|
||||
|
||||
String[] results2 = StrUtil.subBetweenAll(src2,"/*","*/");
|
||||
Assert.assertEquals(0, results2.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ public class HOTP {
|
||||
|
||||
/**
|
||||
* 构造,使用默认密码长度和默认HMAC算法(HmacSHA1)
|
||||
*
|
||||
* @param key 共享密码,RFC 4226要求最少128位
|
||||
*/
|
||||
public HOTP(byte[] key) {
|
||||
this(DEFAULT_PASSWORD_LENGTH, key);
|
||||
|
@ -335,6 +335,7 @@ public final class JSONUtil {
|
||||
* 转为JSON字符串,并写出到write
|
||||
*
|
||||
* @param json JSON
|
||||
* @param writer Writer
|
||||
* @since 5.3.3
|
||||
*/
|
||||
public static void toJsonStr(JSON json, Writer writer) {
|
||||
|
Loading…
Reference in New Issue
Block a user