even better url completion

This commit is contained in:
Mitchell Livingston 2006-11-19 22:20:35 +00:00
parent 95cbdc4900
commit 543d2f0037
1 changed files with 10 additions and 11 deletions

View File

@ -728,20 +728,19 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
if (![urlString isEqualToString: @""])
{
if ([urlString rangeOfString: @"://"].location == NSNotFound)
urlString = [@"http://" stringByAppendingString: urlString];
if ([urlString rangeOfString: @"."].location == NSNotFound)
{
int start = NSMaxRange([urlString rangeOfString: @"://"]);
int beforeCom;
if ((beforeCom = [urlString rangeOfString: @"/" options: 0
range: NSMakeRange(start, [urlString length] - start)].location) != NSNotFound)
urlString = [NSString stringWithFormat: @"%@www.%@.com/%@", [urlString substringToIndex: start],
[urlString substringWithRange: NSMakeRange(start, beforeCom - start)],
if ([urlString rangeOfString: @"."].location == NSNotFound)
{
int beforeCom;
if ((beforeCom = [urlString rangeOfString: @"/"].location) != NSNotFound)
urlString = [NSString stringWithFormat: @"http://www.%@.com/%@",
[urlString substringToIndex: beforeCom],
[urlString substringFromIndex: beforeCom + 1]];
else
urlString = [NSString stringWithFormat: @"http://www.%@.com", urlString];
}
else
urlString = [NSString stringWithFormat: @"%@www.%@.com", [urlString substringToIndex: start],
[urlString substringFromIndex: start]];
urlString = [@"http://" stringByAppendingString: urlString];
}
NSURL * url = [NSURL URLWithString: urlString];