diff Lib/IMPL/DOM/Transform/QueryToDOM.pm @ 244:a02b110da931

refactoring fixed binding to CGI query parameters with multiple values
author sergey
date Mon, 22 Oct 2012 04:09:27 +0400
parents b8c724f6de36
children 129e48bb5afb
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/QueryToDOM.pm	Fri Oct 19 02:23:15 2012 +0400
+++ b/Lib/IMPL/DOM/Transform/QueryToDOM.pm	Mon Oct 22 04:09:27 2012 +0400
@@ -16,8 +16,7 @@
 	my ($this) = @_;
 	
 	$this->templates->{'CGI'} = \&TransformCGI;
-	$this->templates->{'CGIWrapper'} = \&TransformCGI;
-	
+
 	$this->delimiter('[.]');
 	$this->prefix('');
 }
@@ -31,7 +30,8 @@
     my $delim = $this->delimiter;
     
     foreach my $param (grep index($_,$prefix) >= 0 , $query->param()) {
-        length (my $value = $query->param($param)) or next;
+        
+        my @value = grep length($_), $query->param($param) or next;
         
         my @parts = split /$delim/,$param;
         
@@ -46,9 +46,9 @@
                     }
                 } else {
                     if(defined $index) {
-                        $node->{$name}[$index] = $value;
+                        $node->{$name}[$index] = (@value == 1 ? $value[0] : \@value);
                     } else {
-                        $node->{$name} = $value;
+                        $node->{$name} = (@value == 1 ? $value[0] : \@value);
                     }
                 }
             }