Fixed html output

master
Jessica Yu 2012-09-06 15:34:16 -07:00
parent 0491a00a78
commit 816c74cd94
2 changed files with 35 additions and 1 deletions

View File

@ -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 => '<br /><a href="' . unicornify_url(email => $_, size => 128) .'"><img src="' .
unicornify_url(email => $_, size => "100")
. '" /></a><br /><a href="' . $link .
'">Learn more at unicornify.appspot.com</a>';
}
return;
};

24
t/Unicornify.t Normal file
View File

@ -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 => '<br /><a href="'
.unicornify_url(email => 'kumimoko.yo@gmail.com', size => 128)
.'"><img src="'
.unicornify_url(email=>'kumimoko.yo@gmail.com', size => 100)
.'" /></a><br /><a href="http://unicornify.appspot.com/">Learn more at unicornify.appspot.com</a>'));
done_testing;