URLDecode: Copying behaviour of old goodie

master
Rob Emery 2014-09-18 20:15:14 +01:00
parent 924f60b413
commit da73c6f545
2 changed files with 15 additions and 3 deletions

View File

@ -25,10 +25,18 @@ handle query_raw => sub {
s/(^$trigger_words)|($trigger_words$)//i;
s/(^\s+)|(\s+$)//;
my $decoded_url = decodeURIComponent($_);
my $decoded = decodeURIComponent($_);
my $text = "URL Decoded: $decoded_url";
my $html = '<div class="zci--urldecode"><span class="text--secondary">URL Decoded: </span><span class="text--primary url_decoded">'.html_enc($decoded_url).'</span></div>';
if($decoded =~ /^\s+$/)
{
$decoded =~ s/\r/CReturn/;
$decoded =~ s/\n/Newline/;
$decoded =~ s/\t/Tab/;
$decoded =~ s/\s/Space/;
}
my $text = "URL Decoded: $decoded";
my $html = '<div class="zci--urldecode"><span class="text--secondary">URL Decoded: </span><span class="text--primary url_decoded">'.html_enc($decoded).'</span></div>';
return $text, html => $html;
};

View File

@ -57,6 +57,10 @@ ddg_goodie_test(
"URL Decoded: https://duckduckgo.com/",
html => qr#https://duckduckgo\.com/#
),
'%20' => test_zci(
'URL Decoded: Space',
html => qr#URL Decoded:.*Space#
),
'38% of 100 GBP' => undef,
'url decode tool' => undef,
'url decode online' => undef