Skip to content

Commit

Permalink
Merge pull request facebookarchive#543 from mmorearty/https-links
Browse files Browse the repository at this point in the history
https links closes facebookarchive#462
  • Loading branch information
jwang committed Jul 10, 2011
2 parents c78fc97 + 3277a6f commit 2444ca9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Three20Style/Sources/TTStyledTextParser.m
Expand Up @@ -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];
Expand Down

0 comments on commit 2444ca9

Please sign in to comment.