From 401320e08be253770d783be6f55af7e4b9f46341 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 17 Feb 2014 11:12:09 -0500 Subject: [PATCH] Contact: fix display of urls --- UI/Contacts/UIxContactView.m | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 093091248..4880fa667 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -340,21 +340,33 @@ - (NSString *) _formattedURL: (NSString *) url { - NSString *data; + NSRange schemaR; + NSString *schema, *data; if ([url length] > 0) { - if (![[url lowercaseString] rangeOfString: @"://"].length) - url = [NSString stringWithFormat: @"http://%@", url]; - - data = [NSString stringWithFormat: - @"%@", - url, url]; + schemaR = [url rangeOfString: @"://"]; + if (schemaR.length > 0) + { + schema = [url substringToIndex: schemaR.location + schemaR.length]; + data = [url substringFromIndex: schemaR.location + schemaR.length]; + } + else + { + schema = @"http://"; + data = url; + } } else - data = nil; + { + schema = nil; + data = nil; + } - return [self _cardStringWithLabel: nil value: data]; + return [self _cardStringWithLabel: nil + value: data + asLinkScheme: schema + withLinkAttributes: @"target=\"_blank\""]; } @@ -364,8 +376,8 @@ NSString *url; elements = [card childrenWithTag: @"url" - andAttribute: @"type" - havingValue: aType]; + andAttribute: @"type" + havingValue: aType]; if ([elements count] > 0) url = [[elements objectAtIndex: 0] flattenedValuesForKey: @""]; else