2014-06-13 06:59:01 -07:00
|
|
|
package DDG::Goodie::URLEncode;
|
|
|
|
# ABSTRACT: Displays the percent-encoded url.
|
|
|
|
|
|
|
|
use DDG::Goodie;
|
2014-06-24 19:29:03 -07:00
|
|
|
use URI::Escape::XS qw(encodeURIComponent);
|
2014-06-13 06:59:01 -07:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2014-06-24 19:29:03 -07:00
|
|
|
triggers startend => 'url encode', 'encode url', 'urlencode', 'encodeurl', 'url escape', 'escape url', 'urlescape', 'escapeurl';
|
|
|
|
|
|
|
|
primary_example_queries 'url encode https://duckduckgo.com/' , 'encode url xkcd.com/blag';
|
|
|
|
secondary_example_queries 'http://arstechnica.com/ url escape', 'apple.com/mac/ escape url';
|
|
|
|
|
2014-06-23 22:12:47 -07:00
|
|
|
zci answer_type => 'encoded_url';
|
2014-09-27 06:42:57 -07:00
|
|
|
zci is_cached => 1;
|
2014-06-24 19:29:03 -07:00
|
|
|
|
2014-06-23 22:12:47 -07:00
|
|
|
name 'URLEncode';
|
2014-06-24 19:29:03 -07:00
|
|
|
description 'Displays the percent-encoded url';
|
2014-06-23 22:12:47 -07:00
|
|
|
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/URLEncode.pm';
|
|
|
|
category 'computing_tools';
|
|
|
|
topics 'programming', 'web_design';
|
|
|
|
attribution twitter => ['nshanmugham', 'Nishanth Shanmugham'],
|
|
|
|
web => ['http://nishanths.github.io', 'Nishanth Shanmugham'],
|
2015-01-07 10:24:47 -08:00
|
|
|
github => ['nishanths', 'Nishanth Shanmugham'];
|
2014-06-23 22:12:47 -07:00
|
|
|
|
|
|
|
|
2014-06-13 06:59:01 -07:00
|
|
|
handle remainder => sub {
|
2014-10-10 03:01:58 -07:00
|
|
|
my $in = $_;
|
|
|
|
|
|
|
|
return unless $in;
|
|
|
|
|
|
|
|
my $encoded_url = encodeURIComponent($in);
|
2014-06-23 22:12:47 -07:00
|
|
|
|
|
|
|
my $text = "Percent-encoded URL: $encoded_url";
|
|
|
|
|
2014-10-10 03:01:58 -07:00
|
|
|
return $text,
|
|
|
|
structured_answer => {
|
|
|
|
input => [html_enc($in)],
|
|
|
|
operation => 'URL percent-encode',
|
|
|
|
result => html_enc($encoded_url),
|
|
|
|
};
|
2014-06-13 06:59:01 -07:00
|
|
|
};
|
2014-06-23 22:12:47 -07:00
|
|
|
|
2014-06-13 06:59:01 -07:00
|
|
|
1;
|