From: Ian Beckwith Date: Sat, 1 Mar 2008 00:36:32 +0000 (+0000) Subject: Imported upstream version 0.12 X-Git-Tag: upstream/0.12^0 X-Git-Url: http://erislabs.net/gitweb/?p=liburi-template-perl.git;a=commitdiff_plain;h=6ce2a97438a9ca90e550caeefb1d3cecf259ded4;hp=4e234fc969ae1ec9d66e909a05fa0387bfafb331 Imported upstream version 0.12 --- diff --git a/Changes b/Changes index d6a2826..3dc01f2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension URI::Template +0.12 Sun Feb 10 2008 + - Attempt to fix deparse() when the template ends in a variable + 0.11 Fri Feb 08 2008 - require perl 5.6 minimum diff --git a/META.yml b/META.yml index 72d5576..dcc55c4 100644 --- a/META.yml +++ b/META.yml @@ -18,4 +18,4 @@ no_index: requires: URI: 0 perl: 5.6.0 -version: 0.11 +version: 0.12 diff --git a/README b/README index fd4982a..c632c13 100644 --- a/README +++ b/README @@ -55,7 +55,7 @@ AUTHOR Brian Cassidy COPYRIGHT AND LICENSE - Copyright 2007 by Brian Cassidy + Copyright 2008 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/URI/Template.pm b/lib/URI/Template.pm index 8b67663..c7f45a2 100644 --- a/lib/URI/Template.pm +++ b/lib/URI/Template.pm @@ -3,7 +3,7 @@ package URI::Template; use strict; use warnings; -our $VERSION = '0.11'; +our $VERSION = '0.12'; use URI; use URI::Escape (); @@ -172,6 +172,8 @@ sub deparse { 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/; } @@ -188,7 +190,7 @@ Brian Cassidy Ebricas@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Brian Cassidy +Copyright 2008 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/20-deparse.t b/t/20-deparse.t index acb753e..4fac4b3 100644 --- a/t/20-deparse.t +++ b/t/20-deparse.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 11; use_ok( 'URI::Template' ); @@ -34,3 +34,13 @@ use_ok( 'URI::Template' ); my %result = $template->deparse( $uri ); is_deeply( \%result, \%input, 'process => deparse' ); } + +{ + my $template = URI::Template->new( 'http://ex.com/{test}' ); + isa_ok( $template, 'URI::Template' ); + my %input = ( test => 'test' ); + my $uri = $template->process( test => 'test' ); + is( $uri, 'http://ex.com/test' ); + my %result = $template->deparse( $uri ); + is_deeply( \%result, \%input, 'process => deparse w/ multiple chars' ); +}