Skip to content

Commit 16bba30

Browse files
author
Michael Beattie
committed
[#67767620] added regex for valid url
1 parent e6951d9 commit 16bba30

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSource.m

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
114114
EZRCustomFeedCell *cell = (EZRCustomFeedCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomFeedCell"];
115115

116116
NSDictionary *customFeed = [self.sortedFeeds objectAtIndex:indexPath.row];
117+
NSString *customUrl = [customFeed objectForKey:@"url"];
118+
cell.label_url.text = customUrl;
117119

118-
cell.label_url.text = [customFeed objectForKey:@"url"];
120+
if([self isValidUrl:customUrl]){
121+
// Display create button
122+
}
119123

120124
UIView *selectedBackgroundView = [[UIView alloc] init];
121125
[selectedBackgroundView setBackgroundColor: [UIColor EZR_charcoal]];
@@ -125,4 +129,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
125129
}
126130
}
127131

132+
/**
133+
* Check for a letter followed by a dot
134+
*/
135+
- (BOOL)isValidUrl:(NSString *)url
136+
{
137+
NSError *error = NULL;
138+
NSString *pattern = @"[a-z][.]";
139+
NSString *string = url;
140+
NSRange range = NSMakeRange(0, string.length);
141+
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error];
142+
NSArray *matches = [regex matchesInString:string options:NSMatchingReportCompletion range:range];
143+
144+
if (matches.count > 0) {
145+
return TRUE;
146+
}
147+
return FALSE;
148+
}
149+
128150
@end

0 commit comments

Comments
 (0)