UrlQuery增加setStrict方法,区分是否严格模式

This commit is contained in:
Looly 2023-05-28 12:19:17 +08:00
parent 087bcbb325
commit 810924d362

View File

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