public function sanitize($url)
    {
        try {
            $url = Router::url($url);
        } catch (\Exception $ex) {
            return '';
        }

        if (!str_starts_with($url, '/')) {
            return $url;
        }

        if (str_starts_with($url, $this->baseUrl())) {
            $url = str_replace_once($this->baseUrl(), '', $url);
        }

        return $this->localePrefix($url);
    }
public function sanitize($url)
    {
        try {
            $url = Router::url($url);
        } catch (\Exception $ex) {
            return '';
        }

        if (!str_starts_with($url, '/')) {
            return $url;
        }

        if (str_starts_with($url, $this->baseUrl())) {
            $url = str_replace_once($this->baseUrl(), '', $url);
        }

        return $this->localePrefix($url);
    }
public function sanitize ( $ url ) { try { $ url = Router :: url ( $ url ) ; } catch ( \ Exception $ ex ) { return '' ; } if ( ! str_starts_with ( $ url , '/' ) ) { return $ url ; } if ( str_starts_with ( $ url , $ this -> baseUrl ( ) ) ) { $ url = str_replace_once ( $ this -> baseUrl ( ) , '' , $ url ) ; } return $ this -> localePrefix ( $ url ) ; }
Sanitizes the given URL by making sure it's suitable for menu links.

@param string $url Item's URL to sanitize
@return string Valid URL, empty string on error
Sanitizes the given URL by making sure it s suitable for menu links .