From 3277a6f15e69bc782237ae93638c9d27be93eb7b Mon Sep 17 00:00:00 2001 From: Mike Morearty Date: Mon, 2 May 2011 21:49:14 -0700 Subject: [PATCH] In styled text, automatically recognize https links in addition to http links --- src/Three20Style/Sources/TTStyledTextParser.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Three20Style/Sources/TTStyledTextParser.m b/src/Three20Style/Sources/TTStyledTextParser.m index b4c6bea2ca..ca6f15c861 100644 --- a/src/Three20Style/Sources/TTStyledTextParser.m +++ b/src/Three20Style/Sources/TTStyledTextParser.m @@ -114,8 +114,22 @@ - (void)parseURLs:(NSString*)string { while (stringIndex < string.length) { NSRange searchRange = NSMakeRange(stringIndex, string.length - stringIndex); - NSRange startRange = [string rangeOfString:@"http://" options:NSCaseInsensitiveSearch + NSRange httpRange = [string rangeOfString:@"http://" options:NSCaseInsensitiveSearch + range:searchRange]; + NSRange httpsRange = [string rangeOfString:@"https://" options:NSCaseInsensitiveSearch range:searchRange]; + + NSRange startRange; + if (httpRange.location == NSNotFound) { + startRange = httpsRange; + + } else if (httpsRange.location == NSNotFound) { + startRange = httpRange; + + } else { + startRange = (httpRange.location < httpsRange.location) ? httpRange : httpsRange; + } + if (startRange.location == NSNotFound) { NSString* text = [string substringWithRange:searchRange]; TTStyledTextNode* node = [[[TTStyledTextNode alloc] initWithText:text] autorelease];