Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Meta::Helper: concatenate instead of truncate for scalar.
Browse files Browse the repository at this point in the history
Based on input from @mintsoft.

I can see how this makes more sense, so I'm on-board, too.
  • Loading branch information
mwmiller committed Aug 16, 2014
1 parent 9adbe71 commit 823e946
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/DDG/Meta/Helper.pm
Expand Up @@ -37,7 +37,7 @@ encodes entities to safely post random data on HTML output.
=cut

$stash->add_symbol('&html_enc', sub { return (wantarray) ? map { encode_entities($_) } @_ : encode_entities($_[0]) });
$stash->add_symbol('&html_enc', sub { return (wantarray) ? map { encode_entities($_) } @_ : encode_entities(join '', @_) });

=keyword uri_esc
Expand All @@ -50,7 +50,7 @@ values there, this will just lead to double encoding!
=cut

$stash->add_symbol('&uri_esc', sub { return (wantarray) ? map { uri_escape($_) } @_ : uri_escape($_[0]) });
$stash->add_symbol('&uri_esc', sub { return (wantarray) ? map { uri_escape($_) } @_ : uri_escape(join '', @_) });

}

Expand Down
4 changes: 2 additions & 2 deletions t/14-meta-helpers.t
Expand Up @@ -16,7 +16,7 @@ subtest 'html_enc' => sub {
is($res, '<', 'single input');

$res = DDGTest::Goodie::MetaOnly::html_enc('>', '<');
is($res, '&gt;', 'multiple input gets first element');
is($res, '&gt;&lt;', 'multiple input gets concatenated elements');
};

subtest 'array output' => sub {
Expand All @@ -39,7 +39,7 @@ subtest 'uri_esc' => sub {
is($res, '%3C', 'single input');

$res = DDGTest::Goodie::MetaOnly::uri_esc('>', '<');
is($res, '%3E', 'multiple input gets first element');
is($res, '%3E%3C', 'multiple input gets concatenated elements');
};

subtest 'array output' => sub {
Expand Down

0 comments on commit 823e946

Please sign in to comment.