Mvc/Router - normalize multiple slashes in paths, fix regression in 61c9d2f5b1

Although zero (0) is hardly used in url's, when it is used, the function should not suppress it. Fix this by using a closure in array_filter() which only filters empty strings.

ref: https://www.reddit.com/r/opnsense/comments/1hghfzv/health_reporting_rrd_graphs_stopped_working_with/
This commit is contained in:
Ad Schellevis 2024-12-18 08:42:27 +01:00
parent 24485709f3
commit 6145b7f0d0

View File

@ -165,7 +165,10 @@ class Router
*/
private function parsePath(string $path, array $defaults): array
{
$pathElements = array_values(array_filter(explode("/", $path)));
$empty_filter = function($value) {
return $value !== '';
};
$pathElements = array_values(array_filter(explode("/", $path), $empty_filter));
$result = [
"namespace" => null,