Changeset 6731


Ignore:
Timestamp:
Sep 6, 2008, 1:37:33 PM (13 years ago)
Author:
livings124
Message:

[1235] allow the adding of trackers with leading and trailing whitespace

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/CreatorWindowController.m

    r6569 r6731  
    312312    NSString * tracker = (NSString *)object;
    313313   
     314    tracker = [tracker stringByTrimmingWhitespace];
     315   
    314316    if ([tracker rangeOfString: @"://"].location == NSNotFound)
    315317        tracker = [@"http://" stringByAppendingString: tracker];
  • trunk/macosx/NSStringAdditions.h

    r6261 r6731  
    3030- (NSString *) stringByAppendingEllipsis;
    3131
     32- (NSString *) stringByTrimmingWhitespace;
     33
    3234+ (NSString *) stringForFileSize: (uint64_t) size;
    3335
  • trunk/macosx/NSStringAdditions.m

    r6269 r6731  
    3737{
    3838        return [self stringByAppendingString: [NSString ellipsis]];
     39}
     40
     41- (NSString *) stringByTrimmingWhitespace
     42{
     43    NSString * newString = self;
     44    while ([newString length] > 0 && [[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:
     45                                        [newString characterAtIndex: [newString length] - 1]])
     46        newString = [newString substringToIndex: [newString length] - 1];
     47    while ([newString length] > 0 && [[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:
     48                                        [newString characterAtIndex: 0]])
     49        newString = [newString substringFromIndex: 1];
     50   
     51    return newString;
    3952}
    4053
  • trunk/macosx/Torrent.m

    r6634 r6731  
    809809   
    810810    NSString * tracker = [trackers objectAtIndex: i];
     811   
     812    tracker = [tracker stringByTrimmingWhitespace];
     813   
    811814    if ([tracker rangeOfString: @"://"].location == NSNotFound)
    812815    {
Note: See TracChangeset for help on using the changeset viewer.