mirror of
https://github.com/transmission/transmission
synced 2024-12-27 18:18:10 +00:00
better url auto-completion
This commit is contained in:
parent
de7bdd1a87
commit
d4c0e633d2
1 changed files with 9 additions and 2 deletions
|
@ -733,10 +733,17 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
if ([urlString rangeOfString: @"."].location == NSNotFound)
|
if ([urlString rangeOfString: @"."].location == NSNotFound)
|
||||||
{
|
{
|
||||||
int start = NSMaxRange([urlString rangeOfString: @"://"]);
|
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)],
|
||||||
|
[urlString substringFromIndex: beforeCom + 1]];
|
||||||
|
else
|
||||||
urlString = [NSString stringWithFormat: @"%@www.%@.com", [urlString substringToIndex: start],
|
urlString = [NSString stringWithFormat: @"%@www.%@.com", [urlString substringToIndex: start],
|
||||||
[urlString substringFromIndex: start]];
|
[urlString substringFromIndex: start]];
|
||||||
}
|
}
|
||||||
|
NSLog(urlString);
|
||||||
NSURL * url = [NSURL URLWithString: urlString];
|
NSURL * url = [NSURL URLWithString: urlString];
|
||||||
[self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
|
[self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue