Imported upstream version 0.13 upstream/0.13
authorIan Beckwith <ianb@erislabs.net>
Sat, 1 Mar 2008 00:36:32 +0000 (00:36 +0000)
committerIan Beckwith <ianb@erislabs.net>
Sat, 1 Mar 2008 00:36:32 +0000 (00:36 +0000)
Changes
META.yml
lib/URI/Template.pm
t/20-deparse.t

diff --git a/Changes b/Changes
index 3dc01f2..49e998a 100644 (file)
--- 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
 
index dcc55c4..d0165fb 100644 (file)
--- 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
index c7f45a2..b3c1231 100644 (file)
@@ -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 };
index 4fac4b3..1a19346 100644 (file)
@@ -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' );
+}