mirror of
https://github.com/apache/jclouds.git
synced 2025-02-17 23:46:13 +00:00
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 Multimap<String, Object> delegate = LinkedHashMultimap.create();
|
||||||
private final Function<Object, Object> urlDecoder = new Function<Object, Object>() {
|
private final Function<Object, Object> urlDecoder = new Function<Object, Object>() {
|
||||||
public Object apply(Object in) {
|
public Object apply(Object in) {
|
||||||
return urlDecode(in);
|
if (in == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return urlDecode(in.toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean put(String key, Object value) {
|
public boolean put(String key, Object value) {
|
||||||
return super.put(urlDecode(key), urlDecode(value));
|
return super.put(urlDecode(key), urlDecoder.apply(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,11 +112,11 @@ public class Strings2 {
|
|||||||
* @throws IllegalStateException
|
* @throws IllegalStateException
|
||||||
* if encoding isn't {@code UTF-8}
|
* if encoding isn't {@code UTF-8}
|
||||||
*/
|
*/
|
||||||
public static String urlDecode(@Nullable Object in) {
|
public static String urlDecode(@Nullable String in) {
|
||||||
if (in == null)
|
if (in == null)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
return URLDecoder.decode(in.toString(), "UTF-8");
|
return URLDecoder.decode(in, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new IllegalStateException("Bad encoding on input: " + in, e);
|
throw new IllegalStateException("Bad encoding on input: " + in, e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user