mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
UrlQuery增加setStrict方法,区分是否严格模式
This commit is contained in:
parent
087bcbb325
commit
810924d362
@ -45,9 +45,10 @@ public class UrlQuery {
|
|||||||
/**
|
/**
|
||||||
* 是否严格模式,严格模式下,query的name和value中均不允许有分隔符。
|
* 是否严格模式,严格模式下,query的name和value中均不允许有分隔符。
|
||||||
*/
|
*/
|
||||||
private final boolean isStrict;
|
private boolean isStrict;
|
||||||
|
|
||||||
// region ----- of
|
// region ----- of
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建UrlQuery
|
* 构建UrlQuery
|
||||||
*
|
*
|
||||||
@ -149,6 +150,15 @@ public class UrlQuery {
|
|||||||
this.isStrict = isStrict;
|
this.isStrict = isStrict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置是否严格模式
|
||||||
|
*
|
||||||
|
* @param strict 是否严格模式
|
||||||
|
*/
|
||||||
|
public void setStrict(final boolean strict) {
|
||||||
|
isStrict = strict;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加键值对
|
* 增加键值对
|
||||||
*
|
*
|
||||||
@ -267,7 +277,7 @@ public class UrlQuery {
|
|||||||
return build(FormUrlencoded.ALL, FormUrlencoded.ALL, charset, encodePercent);
|
return build(FormUrlencoded.ALL, FormUrlencoded.ALL, charset, encodePercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isStrict){
|
if (isStrict) {
|
||||||
return build(RFC3986.QUERY_PARAM_NAME_STRICT, RFC3986.QUERY_PARAM_VALUE_STRICT, charset, encodePercent);
|
return build(RFC3986.QUERY_PARAM_NAME_STRICT, RFC3986.QUERY_PARAM_VALUE_STRICT, charset, encodePercent);
|
||||||
}
|
}
|
||||||
return build(RFC3986.QUERY_PARAM_NAME, RFC3986.QUERY_PARAM_VALUE, charset, encodePercent);
|
return build(RFC3986.QUERY_PARAM_NAME, RFC3986.QUERY_PARAM_VALUE, charset, encodePercent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user