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:
Diwaker Gupta 2013-08-01 09:36:40 -07:00 committed by Andrew Phillips
parent eabdfe2d92
commit 622aec5566
2 changed files with 7 additions and 4 deletions

View File

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

View File

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