Skip to content

Commit

Permalink
minor regex/perl simplification for isitup
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlang committed May 4, 2012
1 parent 7917c24 commit c7bb91e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/DDG/Spice/IsItUp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ use DDG::Spice;

spice is_cached => 0;

triggers query_lc => qr/^(:?is\s)?([a-z0-9\-\.]+(:?\.[a-z]{2,4})?)(:?\s(up|down|working)\s*(:?\?)?)?$/;
triggers query_lc => qr/^(?:is\s|)([0-9a-z\-]+)(?:(\.[a-z]{2,4})|)\s(?:up|down|working)/;

spice to => 'http://isitup.org/$1.json?callback={{callback}}';

handle matches => sub {
if ($1 && $2 && $4) {
return $2;
} elsif ($2 && $4) {
if ($2 =~ /.com$/) {
return $2;
} else {
return $2 . '.com';
}
}
return $2 ? $1.$2 : $1.'.com';
return;
};

1;

0 comments on commit c7bb91e

Please sign in to comment.