修复部分更新方法过滤失败与单*匹配不精确问题

pull/23/MERGE
JuJu 4 years ago
parent 48cf4250b4
commit 60c815ab76

@ -21,6 +21,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** 星号 */
private static final String START = "*";
/** 斜杠 */
private static final String SLASH = "/";
/**
*
*
@ -477,22 +480,27 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
// 匹配前缀Pattern
result = remainingURI.contains(prefixPattern);
// 匹配失败,直接返回
if (!result)
return false;
// 已经没有星号,判断长度是否符合,并返回
if (formerStarOffset == -1)
{
//清洗请求路径
if (remainingURI.endsWith("/")) {
// 清洗请求路径
if (remainingURI.endsWith(SLASH)) {
remainingURI = remainingURI.substring(0, remainingURI.length() - 1);
}
return remainingURI.length() == prefixPattern.length();
}
// 匹配失败,直接返回
if (!result)
return false;
if (!isEmpty(prefixPattern))
{
// 如果前面还有路径 直接返回
if (!isEmpty(substringBefore(str, prefixPattern))) {
return false;
}
remainingURI = substringAfter(str, prefixPattern);
}
@ -500,6 +508,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
latterStarOffset = indexOf(pattern, START, formerStarOffset + 1);
suffixPattern = substring(pattern, formerStarOffset + 1, latterStarOffset > -1 ? latterStarOffset : pattern.length());
// 判断是否存在第二个 *
if (latterStarOffset == -1) {
// 判断是否还包含斜杠
if(remainingURI.contains(SLASH)) {
return false;
}
}
result = remainingURI.contains(suffixPattern);
// 匹配失败,直接返回
if (!result)

Loading…
Cancel
Save