[Bps-public-commit] r16351 - in Path-Dispatcher/trunk: lib/Path/Dispatcher/Rule

sartak at bestpractical.com sartak at bestpractical.com
Sun Oct 19 04:25:31 EDT 2008


Author: sartak
Date: Sun Oct 19 04:25:31 2008
New Revision: 16351

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm

Log:
 r74105 at onn:  sartak | 2008-10-19 04:25:15 -0400
 Support for prefix matches in the tokens rule, rename the attribute "splitter" to "delimiter"


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm	Sun Oct 19 04:25:31 2008
@@ -35,7 +35,7 @@
     required   => 1,
 );
 
-has splitter => (
+has delimiter => (
     is      => 'ro',
     isa     => 'Str',
     default => ' ',
@@ -45,17 +45,18 @@
     my $self = shift;
     my $path = shift;
 
-    my @orig_tokens = split $self->splitter, $path;
-    my @tokens = @orig_tokens;
+    my @tokens = split $self->delimiter, $path;
+    my @matched;
 
     for my $expected ($self->tokens) {
         return unless @tokens; # too few words
         my $got = shift @tokens;
         return unless $self->_match_token($got, $expected);
+        push @matched, $got;
     }
 
-    return if @tokens; # too many words
-    return [@orig_tokens];
+    my $leftover = join $self->delimiter, @tokens;
+    return \@matched, $leftover;
 }
 
 sub _match_token {



More information about the Bps-public-commit mailing list