diff options
author | franck cuny <franck@lumberjaph.net> | 2010-05-11 16:01:28 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-05-11 16:01:28 +0200 |
commit | ef944e4b6943146edf5a1bc2e56b4dc89ad136ca (patch) | |
tree | 3373e04e3d0aed3dd84ea31747f8aac3f6bad328 /lib/MooseX/Net | |
parent | fix infinite loop (diff) | |
download | moosex-net-api-ef944e4b6943146edf5a1bc2e56b4dc89ad136ca.tar.gz |
replace remainging with nothing
Diffstat (limited to 'lib/MooseX/Net')
-rw-r--r-- | lib/MooseX/Net/API.pm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/MooseX/Net/API.pm b/lib/MooseX/Net/API.pm index 1587810..872d83d 100644 --- a/lib/MooseX/Net/API.pm +++ b/lib/MooseX/Net/API.pm @@ -207,11 +207,17 @@ sub net_api_method { my $path = $options{path}; # replace all args in the url - while ( $path =~ /\$(\w+)/g ) { + my $max_iter = keys %args; + my $i = 0; + while ($path =~ /\$(\w+)/g) { my $match = $1; - if ( my $value = delete $args{$match} ) { + if (my $value = delete $args{$match}) { $path =~ s/\$$match/$value/; } + if (++$i > $max_iter) { + $path =~ s/\$(\w+)//; + last; + } } $path .= '/' if ( $self->api_base_url !~ m!/^! ); |