1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-06 08:27:39 +02:00

multi optional

This commit is contained in:
Koen Punt
2017-04-02 20:34:42 +02:00
parent be64536dcb
commit 72dd5199bd

View File

@@ -254,14 +254,18 @@ class AltoRouter {
$pre = '\.';
}
$optional = $optional !== '' ? '?' : null;
//Older versions of PCRE require the 'P' in (?P<named>)
$pattern = '(?:'
. ($pre !== '' ? $pre : null)
. '('
. ($param !== '' ? "?P<$param>" : null)
. $type
. '))'
. ($optional !== '' ? '?' : null);
. ')'
. $optional
. ')'
. $optional;
$route = str_replace($block, $pattern, $route);
}