Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove ternaries to make code easier to follow

  • Loading branch information...
commit 53308ca29fc2334baa336d959ad48e051d9110f4 1 parent b2bb937
@hunterlang hunterlang authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/DDG/Spice/IsItUp.pm
View
17 lib/DDG/Spice/IsItUp.pm
@@ -9,7 +9,22 @@ triggers query_lc => qr/^((?:is\s|))([0-9a-z\-]+)(?:(\.[a-z]{2,4})|)\s(?:up|down
spice to => 'http://isitup.org/$1.json?callback={{callback}}';
handle matches => sub {
- return $1 ? ($3 ? $2.$3 : $2.'.com') : ($3 ? $2.$3 : $2);
+ # could also be done in 1 line with: return $1 ? ($3 ? $2.$3 : $2.'.com') : ($3 ? $2.$3 : $2);
+
+ if ($3) {
+ # return the domain and the root url
+ return $2.$3;
+ }
+ else {
+ # append .com only if "is" is in the query and there's no other domain given
+ if ($1) {
+ return $2 . '.com';
+ }
+ # otherwise just return without '.com' -- stops false positives from showing zci
+ else {
+ return $2;
+ }
+ }
return;
};
Please sign in to comment.
Something went wrong with that request. Please try again.