Fix issue from the mailing list
Tomas Doran [Thu, 19 Aug 2010 23:01:53 +0000 (23:01 +0000)]
Changes
lib/Catalyst/Plugin/ConfigLoader.pm
t/24-mock-shortappname.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 4ef4f82..f482361 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
 
+    - Fix issue with 2 character app names that are kept in versioned
+      directories (e.g. app called QX in QX-2.1.5/)
     - bump dep on Config::Any to use the -ForceArray Config::General option
       (caelum)
 
index 9e8e574..e137120 100644 (file)
@@ -183,7 +183,7 @@ sub get_config_path {
         || $c->config->{ 'Plugin::ConfigLoader' }->{ file }
         || $c->path_to( $prefix );
 
-    my ( $extension ) = ( $path =~ m{\.(.{1,4})$} );
+    my ( $extension ) = ( $path =~ m{\.([^/\.]{1,4})$} );
 
     if ( -d $path ) {
         $path =~ s{[\/\\]$}{};
diff --git a/t/24-mock-shortappname.t b/t/24-mock-shortappname.t
new file mode 100644 (file)
index 0000000..87fa57a
--- /dev/null
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use Test::More;
+
+{
+    package QX;
+    use strict;
+    use warnings;
+    use Path::Class ();
+
+    use base 'Catalyst::Plugin::ConfigLoader';
+
+    sub config { {} }
+    sub path_to { shift; Path::Class::dir('/home/foo/QX-0.9.5/' . shift); }
+}
+
+my $app = bless {}, 'QX';
+my ($path, $extension) = $app->get_config_path;
+is $path, '/home/foo/QX-0.9.5/qx';
+is $extension, undef;
+
+done_testing;
+