From 816c74cd9408f45e2c0577506447001843339bd2 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Thu, 6 Sep 2012 15:34:16 -0700 Subject: [PATCH] Fixed html output --- lib/DDG/Goodie/Unicornify.pm | 12 +++++++++++- t/Unicornify.t | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 t/Unicornify.t diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm index d2e9abf75..184adc0fa 100644 --- a/lib/DDG/Goodie/Unicornify.pm +++ b/lib/DDG/Goodie/Unicornify.pm @@ -8,8 +8,18 @@ use Unicornify::URL; triggers start => 'unicornify'; + handle remainder => sub { - return img({src=>unicornify_url(email => $_, size => "100")}) if (Email::Valid->address($_)); + my $link = 'http://unicornify.appspot.com/'; + if (Email::Valid->address($_)) { + s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. + + return $_ . '\'s unicorn:', + html => '

Learn more at unicornify.appspot.com'; + } return; }; diff --git a/t/Unicornify.t b/t/Unicornify.t new file mode 100644 index 000000000..6ac661dc8 --- /dev/null +++ b/t/Unicornify.t @@ -0,0 +1,24 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; +use Unicornify::URL; + + +zci answer_type => 'unicornify'; +zci is_cached => 1; +ddg_goodie_test( + [qw( + DDG::Goodie::Unicornify + )], + 'unicornify bob@bob.com' => + test_zci('bob@bob.com\'s unicorn:', + html => '

Learn more at unicornify.appspot.com')); + +done_testing;