Moving code around so $@ is only checked if eval is called, since it currently
Justin Wheeler [Thu, 22 Oct 2009 19:21:26 +0000 (19:21 +0000)]
can get values from lingering old $@s.

lib/Catalyst/Plugin/Static/Simple.pm

index 713d023..769287a 100644 (file)
@@ -27,10 +27,19 @@ sub prepare_action {
         # strip trailing slashes, they'll be added in our regex
         $dir_re =~ s{/$}{};
 
-        my $re = ( $dir =~ m{^qr/}xms ) ? eval $dir : qr{^${dir_re}/};
-        if ($@) {
-            $c->error( "Error compiling static dir regex '$dir': $@" );
+        my $re;
+
+        if ( $dir =~ m{^qr/}xms ) {
+            $re = eval $dir;
+
+            if ($@) {
+                $c->error( "Error compiling static dir regex '$dir': $@" );
+            }
         }
+        else {
+            $re = qr{^${dir_re}/};
+        }
+
         if ( $path =~ $re ) {
             if ( $c->_locate_static_file( $path, 1 ) ) {
                 $c->_debug_msg( 'from static directory' )