Skip to content

Commit

Permalink
fixed a few small Unicode bugs in get command
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 3, 2013
1 parent 8a3ca57 commit 81eba1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -10,6 +10,7 @@
- Improved documentation.
- Improved tests.
- Fixed RFC 6901 compliance of Mojo::JSON::Pointer. (jberger, sri)
- Fixed a few small Unicode bugs in get command.

3.91 2013-03-17
- Improved bad charset handling in Mojo::DOM::HTML.
Expand Down
9 changes: 5 additions & 4 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -46,7 +46,8 @@ sub run {
'r|redirect' => \my $redirect,
'v|verbose' => \my $verbose;

die $self->usage unless my $url = decode 'UTF-8', shift @args // '';
@args = map { decode 'UTF-8', $_ } @args;
die $self->usage unless my $url = shift @args;
my $selector = shift @args;

# Parse header pairs
Expand Down Expand Up @@ -113,7 +114,7 @@ sub run {
warn qq{Problem loading URL "$url". ($err)\n} if $err && !$code;

# JSON Pointer
return unless $selector;
return unless defined $selector;
my $type = $tx->res->headers->content_type // '';
return _json($buffer, $selector) if $type =~ /json/i;

Expand All @@ -126,7 +127,7 @@ sub _json {
return unless my $data = $json->decode(shift);
return unless defined($data = Mojo::JSON::Pointer->new->get($data, shift));
return _say($data) unless ref $data eq 'HASH' || ref $data eq 'ARRAY';
say($json->encode($data));
say $json->encode($data);
}

sub _say {
Expand Down Expand Up @@ -166,7 +167,7 @@ sub _select {
$finished++;
}

unless ($finished) { _say($_) for @$results }
unless ($finished) { say for @$results }
}

1;
Expand Down

0 comments on commit 81eba1f

Please sign in to comment.