Improvements suggested by Fred Kiefer for the current pull request

This commit is contained in:
alotorev 2020-05-04 10:55:41 +03:00
parent 2a547271ad
commit 4aa11f3e48
2 changed files with 23 additions and 10 deletions

View file

@ -2118,22 +2118,29 @@ GS_PRIVATE_INTERNAL(NSURLQueryItem)
- (instancetype) init
{
self = [super init];
self = [self initWithName:nil value:nil];
if(self != nil)
{
GS_CREATE_INTERNAL(NSURLQueryItem);
ASSIGN(internal->_name, @""); //OSX behaviour is to set an empty string for the name property
}
{
}
return self;
}
- (instancetype)initWithName:(NSString *)name
value:(NSString *)value
{
self = [self init];
self = [super init];
if(self != nil)
{
if(name)ASSIGNCOPY(internal->_name, name);
GS_CREATE_INTERNAL(NSURLQueryItem);
if(name)
{
ASSIGNCOPY(internal->_name, name);
}
else
{
ASSIGN(internal->_name, @""); //OSX behaviour is to set an empty string for nil name property
}
ASSIGNCOPY(internal->_value, value);
}
return self;
@ -2267,8 +2274,14 @@ static NSCharacterSet *queryItemCharSet = nil;
{
//OSX behavior is to return nil for a string which cannot be used to initialize valid NSURL object
NSURL* url = [NSURL URLWithString:URLString];
if(url) return [self initWithURL:url resolvingAgainstBaseURL:NO];
else return nil;
if(url)
{
return [self initWithURL:url resolvingAgainstBaseURL:NO];
}
else
{
return nil;
}
}
- (instancetype) initWithURL: (NSURL *)url

View file

@ -353,7 +353,7 @@ GSPathHandling("right");
item = [[NSURLQueryItem alloc] initWithName:@"myName" value:@"myValue"];
PASS_EQUAL(item.name, @"myName", "NSURLQueryItem.name should not be nil");
PASS_EQUAL(item.value, @"myValue", "NSURLQueryItem.value should be nil");
PASS_EQUAL(item.value, @"myValue", "NSURLQueryItem.value should not be nil");
[arp release]; arp = nil;