X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPathRouter.php;h=faf4db4f623744aae48cccd77c595dadc927f4a5;hb=1d9fd23ab3583788fb2e3ae8e641cf83b09ef8df;hp=f24e298a0d24c765faf8e1471dc0607fbfcbb051;hpb=870992af2a62528371265303a596ec85143e040f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/PathRouter.php b/includes/PathRouter.php index f24e298a0d..faf4db4f62 100644 --- a/includes/PathRouter.php +++ b/includes/PathRouter.php @@ -240,6 +240,28 @@ class PathRouter { // matches are tested first $this->sortByWeight(); + $matches = $this->internalParse( $path ); + if ( is_null( $matches ) ) { + // Try with the normalized path (T100782) + $path = wfRemoveDotSegments( $path ); + $path = preg_replace( '#/+#', '/', $path ); + $matches = $this->internalParse( $path ); + } + + // We know the difference between null (no matches) and + // array() (a match with no data) but our WebRequest caller + // expects array() even when we have no matches so return + // a array() when we have null + return is_null( $matches ) ? [] : $matches; + } + + /** + * Match a path against each defined pattern + * + * @param string $path + * @return array|null + */ + protected function internalParse( $path ) { $matches = null; foreach ( $this->patterns as $pattern ) { @@ -248,12 +270,7 @@ class PathRouter { break; } } - - // We know the difference between null (no matches) and - // array() (a match with no data) but our WebRequest caller - // expects array() even when we have no matches so return - // a array() when we have null - return is_null( $matches ) ? [] : $matches; + return $matches; } /**