Skip to content

Commit

Permalink
Avoid warning with non-present optional megasplat.
Browse files Browse the repository at this point in the history
This fixes issue #1144.

If you had a route with an optional megasplat, for example:

```perl
get '/foo/?**?' => sub { ... };
```

and you called it as `/foo`, you'd get a warning:

```
Use of uninitialized value $values[0] in split at
/home/davidp/dev/github/Dancer/lib/Dancer/Route.pm line 136.
```

This fixes it.  However you will still get an empty arrayref.  Part of me would
prefer it return undef instead of an empty arrayref in this case, but that would
be changing existing behaviour which apps in the wild may be relying upon, so
it' probably safest to maintain the same behaviour and just squash the warning.
  • Loading branch information
bigpresh committed Feb 7, 2016
1 parent 2f4e47d commit a5e54dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Dancer/Route.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ sub match {

# megasplat values are split on '/'
if ($token_or_splat[$i] eq 'megasplat') {
$values[$i] = [ split '/' => $values[$i] ];
$values[$i] = [ split '/', $values[$i] || '' ];
}
push @splat, $values[$i];
}
Expand Down

0 comments on commit a5e54dc

Please # to comment.