From 543d2f0037310a6dd7531a2bcbf74fa4a7753ce4 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 19 Nov 2006 22:20:35 +0000 Subject: [PATCH] even better url completion --- macosx/Controller.m | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 15efa9273..cbbcdd3f3 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -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];