File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,13 @@ public static function pattern2regex(string $pattern): string
168168 return preg_replace (self ::URI_PARAM_PATTERN , "([a-zA-Z0-9-_\.]+) " , $ pattern );
169169 }
170170
171+ public static function makeUri (...$ parts )
172+ {
173+ $ uri = implode ("/ " , $ parts );
174+
175+ return "/ " . trim (preg_replace ("#/+# " , "/ " , $ uri ), "/ " );
176+ }
177+
171178 /**
172179 * Whether a offset exists
173180 * @link http://php.net/manual/en/arrayaccess.offsetexists.php
Original file line number Diff line number Diff line change @@ -174,8 +174,8 @@ private function _runBase(string $baseUri)
174174 private function _findSubPipe ()
175175 {
176176 foreach ($ this ->_pipesRegistry as $ baseUri => $ pipe ) {
177- if (preg_match ("#^ " . RequestUri::pattern2regex ($ baseUri ) . "# " , Request::getInstance ()->uri ->getUri ())) {
178- return array ($ baseUri , $ pipe );
177+ if (preg_match ("#^ " . RequestUri::makeUri ( $ this -> _baseUri , RequestUri:: pattern2regex ($ baseUri) ) . "# " , Request::getInstance ()->uri ->getUri ())) {
178+ return array (RequestUri:: makeUri ( $ this -> _baseUri , $ baseUri) , $ pipe );
179179 }
180180 }
181181
@@ -246,7 +246,7 @@ private function _getActionForRoutes(array $routes)
246246 $ runner = null ;
247247
248248 foreach ($ routes as $ pattern => $ action ) {
249- if (RequestUri::isMatch ($ pattern = " / " . trim ($ this ->_baseUri . $ pattern, " / " ), Request::getInstance ()->uri ->getUri ())) {
249+ if (RequestUri::isMatch ($ pattern = RequestUri:: makeUri ($ this ->_baseUri , $ pattern ), Request::getInstance ()->uri ->getUri ())) {
250250 Request::getInstance ()->uri ->setPattern ($ pattern )->build ();
251251 $ runner = $ action ;
252252 break ;
You can’t perform that action at this time.
0 commit comments