Warning in uri_for
Marcus Ramberg [Sun, 18 Mar 2007 19:26:42 +0000 (19:26 +0000)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index f001d38..7b4caae 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 This file documents the revision history for Perl extension Catalyst.
 
+        - Add warning in uri_for
+
 5.7007  2006-03-13 14:18:00
         - Performance and stability improvements to the built-in HTTP server.
         - Don't ignore file uploads if form contains a text field with the
index 04d8d82..ea7117a 100644 (file)
@@ -24,7 +24,7 @@ use Tree::Simple qw/use_weak_refs/;
 use Tree::Simple::Visitor::FindByUID;
 use attributes;
 use utf8;
-use Carp qw/croak/;
+use Carp qw/croak carp/;
 
 BEGIN { require 5.008001; }
 
@@ -949,7 +949,13 @@ sub uri_for {
     };
     
     # join args with '/', or a blank string
-    my $args = ( scalar @args ? '/' . join( '/', map {s/\?/%3F/g; $_} @args ) : '' );
+    my $args = ( scalar @args ? '/' . join( '/', map {
+            unless (defined) {
+               carp "uri_for called with undefined argument";
+               $_='';
+            }
+            s/\?/%3F/g; $_
+        } @args ) : '' );
     $args =~ s/^\/// unless $path;
     my $res =
       URI->new_abs( URI->new_abs( "$path$args", "$basepath$namespace" ), $base )