From: Andrew Rodland Date: Fri, 23 Dec 2011 05:02:30 +0000 (-0500) Subject: Allow dots in path matchers, so that sub (/foo.html) works X-Git-Tag: v0.012~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=c2c68a873d5c6ce0c12759b3e8d3da4c78b18947 Allow dots in path matchers, so that sub (/foo.html) works --- diff --git a/lib/Web/Dispatch/Parser.pm b/lib/Web/Dispatch/Parser.pm index 6ebc51e..bd62652 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 8b7966e..b1bc859 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -254,6 +254,28 @@ my $dp = Web::Dispatch::Parser->new; } { + my $ext = $dp->parse('/foo.bar'); + + is_deeply( + [ $ext->({ PATH_INFO => '/foo.bar' }) ], + [ {} ], + '/foo.bar matches /foo.bar' + ); + + is_deeply( + [ $ext->({ PATH_INFO => '/foo.bar.ext' }) ], + [ {} ], + '/foo.bar matches /foo.bar.ext' + ); + + is_deeply( + [ $ext->({ PATH_INFO => '/foo.notbar' }) ], + [], + '/foo.bar does not match /foo.notbar' + ); +} + +{ my $sub = $dp->parse('/foo/*/...'); is_deeply(