From f849627f9a67b3258fcc7aa3673135e0f55a66fe Mon Sep 17 00:00:00 2001 From: Steven Fisher Date: Wed, 8 Aug 2012 11:07:20 -0700 Subject: [PATCH] initWithBaseURL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes 446. If the URL passed into initWithBaseURL is a file URL rather than a directory URL we will fix it. Without this fix, if you provide "http://myhost/api" as a baseURL and try to get "path", AFNetworking will get http://myhost/path instead of http://myhost/api/path. With the fix, we'll change http://myhost/api to http://myhost/api/. --- AFNetworking/AFHTTPClient.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index 136f24b..d9975b4 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -254,6 +254,9 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { return nil; } + if ( [[url path] length] > 0 && ![[url absoluteString] hasSuffix: @"/"] ) { + url = [url URLByAppendingPathComponent: @""]; + } self.baseURL = url; self.stringEncoding = NSUTF8StringEncoding;