Navigation Menu

Skip to content

Commit

Permalink
fix nasty bug where if you provided the host in the path it would sta…
Browse files Browse the repository at this point in the history
…ck the paths
  • Loading branch information
Justin Palmer committed Mar 14, 2009
1 parent 087f5a1 commit a66c28d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 3 additions & 8 deletions Source/HTTPRiot/HTTPRiotRequest.m
Expand Up @@ -169,21 +169,16 @@ - (NSMutableURLRequest *)configuredRequest

- (NSURL *)composedURI
{
NSString *finalString;
NSURL *tmpURI = [NSURL URLWithString:path];
NSURL *baseURI = [options objectForKey:@"baseURI"];

if([tmpURI host] == nil && [baseURI host] == nil)
[NSException raise:@"UnspecifiedHost" format:@"host wasn't provided in baseURI or path"];

if([tmpURI host])
finalString = [[tmpURI absoluteString] stringByAppendingPathComponent:path];
else
finalString = [[baseURI absoluteString] stringByAppendingPathComponent:path];

tmpURI = [NSURL URLWithString:finalString];

return tmpURI;
return tmpURI;

return [NSURL URLWithString:[[baseURI absoluteString] stringByAppendingPathComponent:path]];
}

#pragma mark - Class Methods
Expand Down
4 changes: 3 additions & 1 deletion Source/Tests/HTTPRiotRequestTest.m
Expand Up @@ -171,13 +171,15 @@ - (void)testDELETE

- (void) testBasicAuth
{
NSError *error = nil;
NSDictionary *auth = [NSDictionary dictionaryWithObjectsAndKeys:@"user", @"username", @"pass", @"password", nil];
NSMutableDictionary *opts = [NSMutableDictionary dictionaryWithDictionary:defaultOptions];
[opts addEntriesFromDictionary:[NSDictionary dictionaryWithObject:auth forKey:@"basicAuth"]];
id person = [HTTPRiotRequest requestWithMethod:kHTTPRiotMethodGet
path:[HTTPRiotTestServer stringByAppendingString:@"/auth"]
options:opts
error:nil];
error:&error];
STAssertNotNil(person, nil);
STAssertNil(error, nil);
}
@end

0 comments on commit a66c28d

Please sign in to comment.