Skip to content

Commit

Permalink
Improve the Nova\Routing\RouteCompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyCyborg committed Dec 12, 2019
1 parent e34daa2 commit e0f043f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Routing/RouteCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function compile()
$domain = '';
}

$path = preg_replace('/\{(\w+?)\?\}/', '{$1}', $uri = $route->uri());
$optionals = $this->extractOptionalParameters($uri = $route->uri());

$optionals = $this->extractOptionalParameters($uri);
$path = preg_replace('/\{(\w+?)\?\}/', '{$1}', $uri);

return with(
new SymfonyRoute($path, $optionals, $route->patterns(), array(), $domain)
Expand All @@ -61,11 +61,7 @@ protected function extractOptionalParameters($uri)
{
preg_match_all('/\{(\w+?)\?\}/', $uri, $matches);

if (! isset($matches[1])) {
return array();
}

return array_fill_keys($matches[1], null);
return isset($matches[1]) ? array_fill_keys($matches[1], null) : array();
}

/**
Expand Down

0 comments on commit e0f043f

Please sign in to comment.