2424@ SuppressWarnings ({"rawtypes" , "unchecked" })
2525public class Cloudinary {
2626
27- public static final String AKAMAI_TOKEN_NAME = "__cld_token__" ;
2827 private static List <String > UPLOAD_STRATEGIES = new ArrayList <String >(Arrays .asList (
2928 "com.cloudinary.android.UploaderStrategy" ,
3029 "com.cloudinary.http42.UploaderStrategy" ,
@@ -257,7 +256,13 @@ protected Map parseConfigUrl(String cloudinaryUrl) {
257256 for (String param : cloudinaryUri .getQuery ().split ("&" )) {
258257 String [] keyValue = param .split ("=" );
259258 try {
260- params .put (keyValue [0 ], URLDecoder .decode (keyValue [1 ], "ASCII" ));
259+ final String value = URLDecoder .decode (keyValue [1 ], "ASCII" );
260+ final String key = keyValue [0 ];
261+ if (isNestedKey (key )) {
262+ putNestedValue (params , key , value );
263+ } else {
264+ params .put (key , value );
265+ }
261266 } catch (UnsupportedEncodingException e ) {
262267 throw new RuntimeException ("Unexpected exception" , e );
263268 }
@@ -266,6 +271,25 @@ protected Map parseConfigUrl(String cloudinaryUrl) {
266271 return params ;
267272 }
268273
274+ private void putNestedValue (Map params , String key , String value ) {
275+ String [] chain = key .split ("[\\ [\\ ]]+" );
276+ Map outer = params ;
277+ String innerKey = chain [0 ];
278+ for (int i = 0 ; i < chain .length -1 ; i ++, innerKey = chain [i ]) {
279+ Map inner = (Map ) outer .get (innerKey );
280+ if (inner == null ) {
281+ inner = new HashMap ();
282+ outer .put (innerKey , inner );
283+ }
284+ outer = inner ;
285+ }
286+ outer .put (innerKey , value );
287+ }
288+
289+ private boolean isNestedKey (String key ) {
290+ return key .matches ("\\ w+\\ [\\ w+\\ ]" );
291+ }
292+
269293 byte [] getUTF8Bytes (String string ) {
270294 try {
271295 return string .getBytes ("UTF-8" );
0 commit comments