From: Robin Edwards Date: Fri, 10 Dec 2010 16:02:13 +0000 (+0000) Subject: adapted to take dashes X-Git-Tag: v0.005~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=1c4f4b78368069e0c626aa5cd70c8fb55f594538 adapted to take dashes --- diff --git a/lib/Web/Dispatch/Parser.pm b/lib/Web/Dispatch/Parser.pm index b731b17..b7d604a 100644 --- a/lib/Web/Dispatch/Parser.pm +++ b/lib/Web/Dispatch/Parser.pm @@ -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 diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index dae8ad4..8405d7d 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -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(