Permalink
Browse files

Fix for #7

  • Loading branch information...
1 parent b4a782a commit 30430916ce18f802601972cb539fc9c40b3e39e3 @stevestreza committed May 2, 2009
Showing with 12 additions and 1 deletion.
  1. +12 −1 Classes/Handlers/Digg/USDiggShrinker.m
@@ -28,6 +28,11 @@ -(void)performShrinkOnURL:(NSURL *)url{
NSURL *newURL = [NSURL URLWithString:newURLString];
NSString *xmlString = [NSString stringWithContentsOfURL:newURL];
+ if(!xmlString){
+ [self doneShrinking:url];
+ return;
+ }
+
NSXMLDocument *xml = [[[NSXMLDocument alloc] initWithXMLString:xmlString options:0 error:nil] autorelease];
if([[[xml rootElement] name] isEqualToString:@"error"]){
@@ -45,7 +50,13 @@ -(void)performShrinkOnURL:(NSURL *)url{
}
+(BOOL)canExpandURL:(NSURL *)url{
- return ([[url host] isEqualToString:@"digg.com"]);
+ BOOL isValid = YES;
+
+#define URLTest(__test) if(!(__test)) isValid = NO;
+ URLTest( [[url host] isEqualToString:@"digg.com"]);
+ URLTest([[[url path] pathComponents] count] == 2); /* '/u12EEU' expands to ['/', 'u12EEU'] */
+
+ return isValid;
}
-(void)performExpandOnURL:(NSURL *)url{

0 comments on commit 3043091

Please sign in to comment.