mirror of https://github.com/apache/jclouds.git
Modify Strings2.urlDecode to input a string.
This is consistent with urlEncode. Also consistently use urlDecoder in DecodingMultimap for values.
This commit is contained in:
parent
eabdfe2d92
commit
622aec5566
|
@ -392,13 +392,16 @@ public final class Uris {
|
|||
private final Multimap<String, Object> delegate = LinkedHashMultimap.create();
|
||||
private final Function<Object, Object> urlDecoder = new Function<Object, Object>() {
|
||||
public Object apply(Object in) {
|
||||
return urlDecode(in);
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
return urlDecode(in.toString());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean put(String key, Object value) {
|
||||
return super.put(urlDecode(key), urlDecode(value));
|
||||
return super.put(urlDecode(key), urlDecoder.apply(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -112,11 +112,11 @@ public class Strings2 {
|
|||
* @throws IllegalStateException
|
||||
* if encoding isn't {@code UTF-8}
|
||||
*/
|
||||
public static String urlDecode(@Nullable Object in) {
|
||||
public static String urlDecode(@Nullable String in) {
|
||||
if (in == null)
|
||||
return null;
|
||||
try {
|
||||
return URLDecoder.decode(in.toString(), "UTF-8");
|
||||
return URLDecoder.decode(in, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalStateException("Bad encoding on input: " + in, e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue