[Bps-public-commit] Path-Dispatcher branch, master, updated. c5ff0953b0e55358b9259bd90c31cb2f7475c4ae
sartak at bestpractical.com
sartak at bestpractical.com
Fri Apr 17 03:19:33 EDT 2009
The branch, master has been updated
via c5ff0953b0e55358b9259bd90c31cb2f7475c4ae (commit)
via f781f723f3f576eff81fab5feda575072ef5e939 (commit)
from 2b4ed8571a0a331378b603b659cb749974672dbd (commit)
Summary of changes:
lib/Path/Dispatcher/Match.pm | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit f781f723f3f576eff81fab5feda575072ef5e939
Author: Shawn M Moore <sartak at gmail.com>
Date: Fri Apr 17 03:19:17 2009 -0400
Handle undef number vars better
diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index f286f80..a07743d 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -55,8 +55,8 @@ sub run_with_number_vars {
# we don't have direct write access to $1 and friends, so we have to
# do this little hack. the only way we can update $1 is by matching
# against a regex (5.10 fixes that)..
- my $re = join '', map { "(\Q$_\E)" } @_;
- my $str = join '', @_;
+ my $re = join '', map { defined($_) ? "(\Q$_\E)" : "(wontmatch)?" } @_;
+ my $str = join '', map { defined($_) ? $_ : "" } @_;
# we need to check length because Perl's annoying gotcha of the empty regex
# actually being an alias for whatever the previously used regex was
commit c5ff0953b0e55358b9259bd90c31cb2f7475c4ae
Author: Shawn M Moore <sartak at gmail.com>
Date: Fri Apr 17 03:19:25 2009 -0400
Anchor the regex for efficiency
diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index a07743d..5ba67b9 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -64,7 +64,7 @@ sub run_with_number_vars {
# we need to do the match anyway, because we have to clear the number vars
($str, $re) = ("x", "x") if length($str) == 0;
- $str =~ $re
+ $str =~ qr{^$re$}
or die "Unable to match '$str' against a copy of itself ($re)!";
$code->();
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list