Changeset 1798
- Timestamp:
- 08/18/04 13:09:22 (4 years ago)
- Files:
-
- trunk/NSAttributedStringMoreAdditions.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/NSAttributedStringMoreAdditions.m
r1793 r1798 294 294 - (void) makeLinkAttributesAutomatically { 295 295 // catch well-formed urls like "http://www.apple.com", "www.apple.com" or "irc://irc.javelin.cc" 296 AGRegex *regex = [AGRegex regexWithPattern:@"(?:[\\w-]+://|www\\.)(?:[\\w-:]+@)?(?:[\\w-]+\\.)+[\\w{2,4}]+(?:\\:\\d+)?(?:/[\\w$\\-_.+!*',= \\\\()%@&;#?~]*)*" options:AGRegexCaseInsensitive];296 AGRegex *regex = [AGRegex regexWithPattern:@"(?:[\\w-]+://|www\\.)(?:[\\w-:]+@)?(?:[\\w-]+\\.)+[\\w{2,4}]+(?:\\:\\d+)?(?:/[\\w$\\-_.+!*',=:/\\\\()%@&;#?~]*)*" options:AGRegexCaseInsensitive]; 297 297 NSArray *matches = [regex findAllInString:[self string]]; 298 298 NSEnumerator *enumerator = [matches objectEnumerator]; … … 302 302 NSRange foundRange = [match range]; 303 303 NSString *currentLink = [self attribute:NSLinkAttributeName atIndex:foundRange.location effectiveRange:NULL]; 304 if( ! currentLink ) [self addAttribute:NSLinkAttributeName value: [match group]range:foundRange];304 if( ! currentLink ) [self addAttribute:NSLinkAttributeName value:( [[match group] hasPrefix:@"www."] ? [@"http://" stringByAppendingString:[match group]] : [match group] ) range:foundRange]; 305 305 } 306 306
