From 5ea1ac36de0445293009b06d3a28620e63f92916 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Thu, 23 Jan 2014 22:59:49 +0000 Subject: [PATCH] Imported Upstream version 0.18 --- Changes | 3 +++ META.yml | 2 +- README | 2 +- lib/URI/Template.pm | 14 ++++---------- t/cases/extended-tests.json | 4 ++-- t/cases/negative-tests.json | 8 ++++++++ t/cases/spec-examples-by-section.json | 2 ++ 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Changes b/Changes index a9677c3..edd4a6f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension URI::Template +0.18 2013-12-05 + - Fix empty hash/array special casing to not return anything + 0.17 2013-03-11 - Special case return from empty hash and array values in query strings diff --git a/META.yml b/META.yml index fc3f038..4ce2ac9 100644 --- a/META.yml +++ b/META.yml @@ -27,4 +27,4 @@ requires: resources: license: http://dev.perl.org/licenses/ repository: http://github.com/bricas/uri-template -version: 0.17 +version: 0.18 diff --git a/README b/README index 0010981..b8e6224 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ SYNOPSIS DESCRIPTION This module provides a wrapper around URI templates as described in RFC - 6570: http://tools.ietf.org/html/rfc6570 + 6570: . INSTALLATION perl Makefile.PL diff --git a/lib/URI/Template.pm b/lib/URI/Template.pm index 390f6a6..54a73ac 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.17'; +our $VERSION = '0.18'; use URI; use URI::Escape (); @@ -123,10 +123,7 @@ sub _tostring_query { $join = '&' if $exp->{ op } =~ /[?&]/; if ( ref $value eq 'ARRAY' ) { - if( !@$value ) { - return if $var->{ explode }; - return $var->{ name } . '='; - } + return if !@$value; if ( $var->{ explode } ) { return join( $join, map { $var->{ name } . '=' . _quote( $_, $safe ) } @$value ); @@ -137,10 +134,7 @@ sub _tostring_query { } } elsif ( ref $value eq 'HASH' ) { - if( !keys %$value ) { - return if $var->{ explode }; - return $var->{ name } . '='; - } + return if !keys %$value; if ( $var->{ explode } ) { return join( $join, @@ -341,7 +335,7 @@ URI::Template - Object for handling URI templates (RFC 6570) =head1 DESCRIPTION This module provides a wrapper around URI templates as described in RFC 6570: -http://tools.ietf.org/html/rfc6570 +L<< http://tools.ietf.org/html/rfc6570 >>. =head1 INSTALLATION diff --git a/t/cases/extended-tests.json b/t/cases/extended-tests.json index 959840e..fd69744 100644 --- a/t/cases/extended-tests.json +++ b/t/cases/extended-tests.json @@ -92,9 +92,9 @@ "testcases":[ [ "{/empty_list}", [ "" ] ], [ "{/empty_list*}", [ "" ] ], - [ "{?empty_list}", [ "?empty_list="] ], + [ "{?empty_list}", [ ""] ], [ "{?empty_list*}", [ "" ] ], - [ "{?empty_assoc}", [ "?empty_assoc=" ] ], + [ "{?empty_assoc}", [ "" ] ], [ "{?empty_assoc*}", [ "" ] ] ] }, diff --git a/t/cases/negative-tests.json b/t/cases/negative-tests.json index dca9c9e..552a6bf 100644 --- a/t/cases/negative-tests.json +++ b/t/cases/negative-tests.json @@ -5,6 +5,9 @@ "id" : "thing", "var" : "value", "hello" : "Hello World!", + "with space" : "fail", + " leading_space" : "Hi!", + "trailing_space " : "Bye!", "empty" : "", "path" : "/foo/bar", "x" : "1024", @@ -26,6 +29,9 @@ [ "{hello:2*}", false ] , [ "{??hello}", false ] , [ "{!hello}", false ] , + [ "{with space}", false], + [ "{ leading_space}", false], + [ "{trailing_space }", false], [ "{=path}", false ] , [ "{$var}", false ], [ "{|var*}", false ], @@ -41,6 +47,8 @@ [ "{;keys:1*}", false ], [ "?{-join|&|var,list}" , false ], [ "/people/{~thing}", false], + [ "/{default-graph-uri}", false ], + [ "/sparql{?query,default-graph-uri}", false ], [ "/sparql{?query){&default-graph-uri*}", false ], [ "/resolution{?x, y}" , false ] diff --git a/t/cases/spec-examples-by-section.json b/t/cases/spec-examples-by-section.json index dbb00ff..5aef182 100644 --- a/t/cases/spec-examples-by-section.json +++ b/t/cases/spec-examples-by-section.json @@ -109,6 +109,8 @@ }, "testcases" : [ ["{+var}", "value"], + ["{/var,empty}", "/value/"], + ["{/var,undef}", "/value"], ["{+hello}", "Hello%20World!"], ["{+half}", "50%25"], ["{base}index", "http%3A%2F%2Fexample.com%2Fhome%2Findex"], -- 2.11.0