protected function normalizeFormat($format, $route): array
    {
        // Normalize the URL
        $route['url'] = $this->normalizeUri($route['url']);
        // Transform the URLs depending on the format requested
        switch ($format) {
            // React & Vue routes have a leading / and {slug} -> :slug
            case $this::ROUTE_FORMAT_REACT:
            case $this::ROUTE_FORMAT_VUE:
                $matchRegEx = '`{(.*?)}`i';
                $replaceRegEx = ':$1';
                $route['url'] = preg_replace($matchRegEx, $replaceRegEx, $route['url']);
                // Add a leading /
                $route['url'] = '/'.ltrim($route['url'], '/');
                break;

            // Craft-style URLs don't need to be changed
            case $this::ROUTE_FORMAT_CRAFT:
            default:
                // Do nothing
                break;
        }

        return $route;
    }
protected function normalizeFormat($format, $route): array
    {
        // Normalize the URL
        $route['url'] = $this->normalizeUri($route['url']);
        // Transform the URLs depending on the format requested
        switch ($format) {
            // React & Vue routes have a leading / and {slug} -> :slug
            case $this::ROUTE_FORMAT_REACT:
            case $this::ROUTE_FORMAT_VUE:
                $matchRegEx = '`{(.*?)}`i';
                $replaceRegEx = ':$1';
                $route['url'] = preg_replace($matchRegEx, $replaceRegEx, $route['url']);
                // Add a leading /
                $route['url'] = '/'.ltrim($route['url'], '/');
                break;

            // Craft-style URLs don't need to be changed
            case $this::ROUTE_FORMAT_CRAFT:
            default:
                // Do nothing
                break;
        }

        return $route;
    }
protected function normalizeFormat ( $ format , $ route ) : array { // Normalize the URL $ route [ 'url' ] = $ this -> normalizeUri ( $ route [ 'url' ] ) ; // Transform the URLs depending on the format requested switch ( $ format ) { // React & Vue routes have a leading / and {slug} -> :slug case $ this :: ROUTE_FORMAT_REACT : case $ this :: ROUTE_FORMAT_VUE : $ matchRegEx = '`{(.*?)}`i' ; $ replaceRegEx = ':$1' ; $ route [ 'url' ] = preg_replace ( $ matchRegEx , $ replaceRegEx , $ route [ 'url' ] ) ; // Add a leading / $ route [ 'url' ] = '/' . ltrim ( $ route [ 'url' ] , '/' ) ; break ; // Craft-style URLs don't need to be changed case $ this :: ROUTE_FORMAT_CRAFT : default : // Do nothing break ; } return $ route ; }
Normalize the routes based on the format

@param string $format 'Craft'|'React'|'Vue'
@param array  $route

@return array
Normalize the routes based on the format