From 917525490f5d8e583f4b53dcd2d792b9e6f42c88 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sat, 1 Mar 2008 00:36:32 +0000 Subject: [PATCH] Imported upstream version 0.13 --- Changes | 3 +++ META.yml | 2 +- lib/URI/Template.pm | 6 ++---- t/20-deparse.t | 10 +++++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 3dc01f2..49e998a 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ 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 diff --git a/META.yml b/META.yml index dcc55c4..d0165fb 100644 --- a/META.yml +++ b/META.yml @@ -18,4 +18,4 @@ no_index: requires: URI: 0 perl: 5.6.0 -version: 0.12 +version: 0.13 diff --git a/lib/URI/Template.pm b/lib/URI/Template.pm index c7f45a2..b3c1231 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.12'; +our $VERSION = '0.13'; use URI; use URI::Escape (); @@ -172,9 +172,7 @@ 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/; + $self->{ deparse_re } = qr/^${templ}$/; } my @matches = $uri =~ $self->{ deparse_re }; diff --git a/t/20-deparse.t b/t/20-deparse.t index 4fac4b3..1a19346 100644 --- a/t/20-deparse.t +++ b/t/20-deparse.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 13; use_ok( 'URI::Template' ); @@ -44,3 +44,11 @@ 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' ); +} -- 2.11.0