Navigation Menu

Skip to content

Commit

Permalink
renamed no to not
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 21, 2013
1 parent 729f59c commit df4cf4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -7,7 +7,7 @@
- Deprecated Mojo::UserAgent::https_proxy in favor of
Mojo::UserAgent::Proxy::https.
- Deprecated Mojo::UserAgent::no_proxy in favor of
Mojo::UserAgent::Proxy::no.
Mojo::UserAgent::Proxy::not.
- Deprecated Mojo::UserAgent::need_proxy in favor of
Mojo::UserAgent::Proxy::is_needed.
- Deprecated Mojo::UserAgent::name in favor of
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/UserAgent/Proxy.pm
Expand Up @@ -3,13 +3,13 @@ use Mojo::Base -base;

use List::Util 'first';

has [qw(http https no)];
has [qw(http https not)];

sub detect {
my $self = shift;
$self->http($ENV{HTTP_PROXY} || $ENV{http_proxy});
$self->https($ENV{HTTPS_PROXY} || $ENV{https_proxy});
return $self->no([split /,/, $ENV{NO_PROXY} || $ENV{no_proxy} || '']);
return $self->not([split /,/, $ENV{NO_PROXY} || $ENV{no_proxy} || '']);
}

sub inject {
Expand All @@ -31,7 +31,7 @@ sub inject {
}

sub is_needed {
!first { $_[1] =~ /\Q$_\E$/ } @{$_[0]->no || []};
!first { $_[1] =~ /\Q$_\E$/ } @{$_[0]->not || []};
}

1;
Expand Down Expand Up @@ -72,10 +72,10 @@ Proxy server to use for HTTP and WebSocket requests.
Proxy server to use for HTTPS and WebSocket requests.
=head2 no
=head2 not
my $no = $proxy->no;
$ua = $proxy->no([qw(localhost intranet.mojolicio.us)]);
my $not = $proxy->not;
$ua = $proxy->not([qw(localhost intranet.mojolicio.us)]);
Domains that don't require a proxy server to be used.
Expand Down
2 changes: 2 additions & 0 deletions t/mojo/proxy.t
Expand Up @@ -24,6 +24,8 @@ use Mojo::UserAgent::Proxy;
local $ENV{https_proxy} = 'tunnel.example.com';
local $ENV{no_proxy} = 'localhost,localdomain,foo.com,example.com';
$proxy->detect;
is_deeply $proxy->not,
['localhost', 'localdomain', 'foo.com', 'example.com'], 'right list';
is $proxy->http, 'proxy.example.com', 'right proxy';
is $proxy->https, 'tunnel.example.com', 'right proxy';
ok $proxy->is_needed('dummy.mojolicio.us'), 'proxy needed';
Expand Down

0 comments on commit df4cf4c

Please sign in to comment.