adapted to take dashes
Robin Edwards [Fri, 10 Dec 2010 16:02:13 +0000 (16:02 +0000)]
lib/Web/Dispatch/Parser.pm
t/dispatch_parser.t

index b731b17..b7d604a 100644 (file)
@@ -165,7 +165,7 @@ sub _url_path_segment_match {
     /\G(?:(?=[+|\)])|$)/gc and
       return '';
     # word chars only -> exact path part match
-    /\G(\w+)/gc and
+    /\G([\w\-]+)/gc and
       return "\Q$1";
     # ** -> capture unlimited path parts
     /\G\*\*/gc and
index dae8ad4..8405d7d 100644 (file)
@@ -93,6 +93,22 @@ ok(
 }
 
 {
+   my $post = $dp->parse('/foo-bar/*');
+
+   is_deeply(
+     [ $post->({ PATH_INFO => '/foo-bar/one' }) ],
+     [ {}, 'one' ],
+     '/foo-bar/one parses out one'
+   );
+
+   is_deeply(
+     [ $post->({ PATH_INFO => '/foo-bar/one/' }) ],
+     [],
+     '/foo-bar/one/ does not match'
+   );
+}
+
+{
    my $combi = $dp->parse('GET+/post/*');
 
    is_deeply(