sub parse {
my ($self, $spec) = @_;
+ $spec =~ s/\s+//g; # whitespace is not valid
return $self->_cache->{$spec} ||= $self->_parse_spec($spec);
}
my ($self, $spec, $nested) = @_;
for ($_[1]) {
my @match;
- /^\G\s*/; # eat leading whitespace
PARSE: { do {
push @match, $self->_parse_spec_section($_)
or $self->_blam("Unable to work out what the next section is");
return do {
my $match = $self->_parse_spec_section($_);
return sub {
- return {} unless $match->(@_);
+ return {} unless my @discard = $match->(@_);
return;
};
};
sub _url_extension_match {
my ($self, $str, $extension) = @_;
- if ($extension eq '*') {
- sub {
- if ((my $tmp = shift->{PATH_INFO}) =~ s/\.(\w+)$//) {
- ({ PATH_INFO => $tmp }, $1);
- } else {
- ();
- }
- };
- } else {
- sub {
- if ((my $tmp = shift->{PATH_INFO}) =~ s/\.\Q${extension}\E$//) {
- ({ PATH_INFO => $tmp });
- } else {
- ();
- }
- };
- }
+ match_extension($extension);
}
sub _parse_param_handler {