]> granicus.if.org Git - transmission/commitdiff
support pasting magnet links into the torrent table
authorMitchell Livingston <livings124@transmissionbt.com>
Tue, 27 Dec 2011 23:19:14 +0000 (23:19 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Tue, 27 Dec 2011 23:19:14 +0000 (23:19 +0000)
macosx/TorrentTableView.m

index 64fa49240f18d6281a1d4902171bab35415fd29e..ca58ba0bb9d17718ccc2cb5a812bc2e2ab5ca929 100644 (file)
             NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil];
             for (NSString * pbItem in items)
             {
-                for (NSTextCheckingResult * result in [detector matchesInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
-                    [fController openURL: [[result URL] absoluteString]];
+                if ([pbItem rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
+                    [fController openURL: pbItem];
+                else
+                {
+                    #warning only accept full text?
+                    for (NSTextCheckingResult * result in [detector matchesInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
+                        [fController openURL: [[result URL] absoluteString]];
+                }
             }
         }
     }
                 NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil];
                 for (NSString * pbItem in items)
                 {
-                    if ([detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
+                    if (([pbItem rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
+                        || [detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
                         return YES;
                 }
             }