diff options
Diffstat (limited to 'iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m')
-rwxr-xr-x | iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m index 833baad..6c7a856 100755 --- a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m +++ b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m @@ -18,7 +18,8 @@ */ #import "CDVInvokedUrlCommand.h" -#import "JSONKit.h" +#import "CDVJSON.h" +#import "NSData+Base64.h" @implementation CDVInvokedUrlCommand @@ -58,9 +59,36 @@ _className = className; _methodName = methodName; } + [self massageArguments]; return self; } +- (void)massageArguments +{ + NSMutableArray* newArgs = nil; + + for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) { + id arg = [_arguments objectAtIndex:i]; + if (![arg isKindOfClass:[NSDictionary class]]) { + continue; + } + NSDictionary* dict = arg; + NSString* type = [dict objectForKey:@"CDVType"]; + if (!type || ![type isEqualToString:@"ArrayBuffer"]) { + continue; + } + NSString* data = [dict objectForKey:@"data"]; + if (!data) { + continue; + } + if (newArgs == nil) { + newArgs = [NSMutableArray arrayWithArray:_arguments]; + _arguments = newArgs; + } + [newArgs replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]]; + } +} + - (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict { NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments]; |