1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-04 10:27:46 +01:00
Telegram/thirdparty/GDFileManager/GDURLUtilities.m
2015-10-01 19:19:52 +03:00

35 lines
1.1 KiB
Objective-C
Executable File

//
// GDURLUtilities.m
// GDFileManagerExample
//
// Created by Graham Dennis on 21/06/13.
// Copyright (c) 2013 Graham Dennis. All rights reserved.
//
#import "GDURLUtilities.h"
#import "thirdparty/AFNetworking/AFHTTPClient.h"
NSString * GDURLQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding)
{
return AFQueryStringFromParametersWithEncoding(parameters, encoding);
}
NSDictionary *GDParametersFromURLQueryStringWithEncoding(NSString *queryString, NSStringEncoding encoding)
{
NSArray *pairs = [queryString componentsSeparatedByString:@"&"];
NSMutableDictionary *parameters = [NSMutableDictionary new];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:@"="];
if ([kv count] != 2) {
// FIXME: report error
continue;
}
NSString *value = [kv[1] stringByReplacingPercentEscapesUsingEncoding:encoding];
NSString *key = [kv[0] stringByReplacingPercentEscapesUsingEncoding:encoding];
[parameters setObject:value forKey:key];
}
return [parameters copy];
}