Skip to content

Commit

Permalink
Fixed UUV warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Oct 25, 2010
1 parent f1b7d33 commit d8ffdf4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Plack/Middleware/JSONP.pm
Expand Up @@ -6,14 +6,21 @@ use URI::Escape ();

use Plack::Util::Accessor qw/callback_key/;

sub prepare_app {
my $self = shift;
unless (defined $self->callback_key) {
$self->callback_key('callback');
}
}

sub call {
my($self, $env) = @_;
my $res = $self->app->($env);
$self->response_cb($res, sub {
my $res = shift;
if (defined $res->[2] && ref $res->[2] eq 'ARRAY' && @{$res->[2]} == 1) {
my $h = Plack::Util::headers($res->[1]);
my $callback_key = quotemeta($self->callback_key) || 'callback';
my $callback_key = $self->callback_key;
if ($h->get('Content-Type') =~ m!/(?:json|javascript)! &&
$env->{QUERY_STRING} =~ /(?:^|&)$callback_key=([^&]+)/) {
my $cb = URI::Escape::uri_unescape($1);
Expand Down

0 comments on commit d8ffdf4

Please sign in to comment.