lemonldap-ng/lemonldap-ng-common/lib/Lemonldap/NG/Common/FormEncode.pm

35 lines
649 B
Perl
Raw Normal View History

package Lemonldap::NG::Common::FormEncode;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our $VERSION = '2.0.0';
our @EXPORT_OK = qw(build_urlencoded);
our @EXPORT = qw(build_urlencoded);
BEGIN {
require Plack::Request;
if ( $Plack::Request::VERSION < '1.0040' ) {
require URI::Escape;
eval <<'EOT';
sub build_urlencoded {
my(%h)=@_;
my $v;
return join('&',map {$v=URI::Escape::uri_escape($h{$_});"$_=$v"} keys %h);
}
EOT
}
else {
require WWW::Form::UrlEncoded;
eval <<'EOT';
sub build_urlencoded {
return WWW::Form::UrlEncoded::build_urlencoded(@_);
}
EOT
}
}
1;