Simplify domain & host parsing

This commit is contained in:
Haoyu Qiu
2017-11-26 12:46:00 +08:00
parent bbb7981ee8
commit d5b5679ec1

View File

@ -119,11 +119,12 @@ GCDWebServer *webServer =nil;
NSString* rawExceptions = [defaults stringForKey:@"ProxyExceptions"]; NSString* rawExceptions = [defaults stringForKey:@"ProxyExceptions"];
if (rawExceptions) { if (rawExceptions) {
NSCharacterSet* seps = [NSCharacterSet characterSetWithCharactersInString:@", 、"];
NSCharacterSet* whites = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSCharacterSet* whites = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSMutableCharacterSet* seps = [NSMutableCharacterSet characterSetWithCharactersInString:@",、"];
[seps formUnionWithCharacterSet:whites];
NSArray* exceptions = [rawExceptions componentsSeparatedByCharactersInSet:seps]; NSArray* exceptions = [rawExceptions componentsSeparatedByCharactersInSet:seps];
for (NSString* rawDomainOrHost in exceptions) { for (NSString* domainOrHost in exceptions) {
NSString* domainOrHost = [rawDomainOrHost stringByTrimmingCharactersInSet:whites];
if ([domainOrHost length] > 0) { if ([domainOrHost length] > 0) {
[args addObject:@"-x"]; [args addObject:@"-x"];
[args addObject:domainOrHost]; [args addObject:domainOrHost];