Revision history for Perl extension URI::Template
+0.13 Tue Feb 12 2008
+ - Properly terminate deparse regex (Karen Cravens)
+
0.12 Sun Feb 10 2008
- Attempt to fix deparse() when the template ends in a variable
use strict;
use warnings;
-our $VERSION = '0.12';
+our $VERSION = '0.13';
use URI;
use URI::Escape ();
my $templ = $self->as_string;
$self->{ vars_list } = [ $templ =~ /{(.+?)}/g ];
$templ =~ s/{.+?}/(.+?)/g;
- # If the template ends w/ a match, then make it greedy.
- $templ =~ s/\Q(.+?)\E$/(.+)/;
- $self->{ deparse_re } = qr/$templ/;
+ $self->{ deparse_re } = qr/^${templ}$/;
}
my @matches = $uri =~ $self->{ deparse_re };
use strict;
use warnings;
-use Test::More tests => 11;
+use Test::More tests => 13;
use_ok( 'URI::Template' );
my %result = $template->deparse( $uri );
is_deeply( \%result, \%input, 'process => deparse w/ multiple chars' );
}
+
+{
+ my $template = URI::Template->new( 'http://ex.com/profile/{username}/address' );
+ isa_ok( $template, 'URI::Template' );
+ my $uri = 'http://ex.com/profile/Test/addresses';
+ my %result = $template->deparse( $uri );
+ is_deeply( \%result, { username => undef }, 'regex properly terminated' );
+}