summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-11-03 18:49:00 +0100
committerfranck cuny <franck@lumberjaph.net>2010-11-03 18:49:00 +0100
commitf1a670f48251e0d4fd34cafc6b10e4fcc5e7cc9d (patch)
tree915cee9b80012d3fce30852f888d2032a8e63d17
parentadd new test (diff)
downloadnet-http-spore-f1a670f48251e0d4fd34cafc6b10e4fcc5e7cc9d.tar.gz
remove remaining :name in path
-rw-r--r--lib/Net/HTTP/Spore/Request.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Net/HTTP/Spore/Request.pm b/lib/Net/HTTP/Spore/Request.pm
index 8604f35..8a42e16 100644
--- a/lib/Net/HTTP/Spore/Request.pm
+++ b/lib/Net/HTTP/Spore/Request.pm
@@ -226,7 +226,7 @@ sub uri {
 
     my $path = URI::Escape::uri_escape($path_info || '', $path_escape_class);
 
-    if (defined $query_string) {
+    if (defined $query_string && length($query_string) > 0) {
         $path .= '?' . $query_string;
     }
 
@@ -284,7 +284,7 @@ sub finalize {
         my $v = $params->[++$i];
         my $modified = 0;
 
-        if ($path_info =~ s/\:$k/$v/) {
+        if ($path_info && $path_info =~ s/\:$k/$v/) {
             $modified++;
         }
         
@@ -305,10 +305,17 @@ sub finalize {
         }
 
         if ($modified == 0) {
-            push @$query, $k.'='.$v;
+            if (defined $v) {
+                push @$query, $k.'='.$v;
+            }else{
+                push @$query, $k;
+            }
         }
     }
 
+    # clean remaining :name in url
+    $path_info =~ s/:\w+//g if $path_info;
+
     my $query_string;
     if (scalar @$query) {
         $query_string = join('&', @$query);