1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-07 00:46:51 +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 = '\.'; $pre = '\.';
} }
$optional = $optional !== '' ? '?' : null;
//Older versions of PCRE require the 'P' in (?P<named>) //Older versions of PCRE require the 'P' in (?P<named>)
$pattern = '(?:' $pattern = '(?:'
. ($pre !== '' ? $pre : null) . ($pre !== '' ? $pre : null)
. '(' . '('
. ($param !== '' ? "?P<$param>" : null) . ($param !== '' ? "?P<$param>" : null)
. $type . $type
. '))' . ')'
. ($optional !== '' ? '?' : null); . $optional
. ')'
. $optional;
$route = str_replace($block, $pattern, $route); $route = str_replace($block, $pattern, $route);
} }