Show
Ignore:
Timestamp:
05/27/08 02:35:08 (22 months ago)
Author:
eevee
Message:

Fixed uri_for encoding its query args more and more on successive calls with the same hashref containing an arrayref. This is actually a Catalyst "problem", but it seems to have "working as intended" status. (#312)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee.pm

    r428 r440  
    88use Image::Size; 
    99use LWP::UserAgent; 
     10use Storable qw/dclone/; 
    1011use Time::Out qw/timeout/; 
    1112use YAML qw//; 
     
    139140sub uri { 
    140141    my ($self, $con, $sub, @args) = @_; 
     142 
    141143    my $url = $self->uri_for( 
    142144        $self->controller($con)->action_for($sub), 
     
    144146    ); 
    145147    $url =~ tr/&/;/; # fuck ampersands 
     148 
    146149    return $url; 
     150} 
     151 
     152=head2 uri_for 
     153 
     154Override of Catalyst's uri_for that clones parameters before passing them 
     155along, so I don't have to worry about e.g. reusing the same query args hashref 
     156several times in a template. 
     157 
     158=cut 
     159 
     160sub uri_for { 
     161    my ($self, @etc) = @_; 
     162 
     163    # Only the last parameter can be a query arg hashref 
     164    if (@etc and ref $etc[-1] eq 'HASH') { 
     165        $etc[-1] = dclone $etc[-1]; 
     166    } 
     167 
     168    return $self->next::method(@etc); 
    147169} 
    148170