src/BoomCMS/Support/Helpers/URL.php
public static function sanitise($url)
    {
        $url = trim($url);
        $url = strtolower($url);
        $url = parse_url($url, PHP_URL_PATH);        // Make sure it doesn't contain a hostname
        $url = preg_replace('|/+|', '/', $url);        // Remove duplicate forward slashes.

        if ($url !== '/') {
            // Remove trailing or preceeding slashes
            $url = trim($url, '/');
        }

        $url = preg_replace('|[^'.preg_quote('-').'\/\pL\pN\s]+|u', '', $url); // Remove all characters that are not a hypeh, letters, numbers, or forward slash
        $url = preg_replace('|['.preg_quote('-').'\s]+|u', '-', $url); // Replace all hypens and whitespace by a single hyphen

        return $url;
    }
public static function sanitise($url)
    {
        $url = trim($url);
        $url = strtolower($url);
        $url = parse_url($url, PHP_URL_PATH);        // Make sure it doesn't contain a hostname
        $url = preg_replace('|/+|', '/', $url);        // Remove duplicate forward slashes.

        if ($url !== '/') {
            // Remove trailing or preceeding slashes
            $url = trim($url, '/');
        }

        $url = preg_replace('|[^'.preg_quote('-').'\/\pL\pN\s]+|u', '', $url); // Remove all characters that are not a hypeh, letters, numbers, or forward slash
        $url = preg_replace('|['.preg_quote('-').'\s]+|u', '-', $url); // Replace all hypens and whitespace by a single hyphen

        return $url;
    }
public static function sanitise ( $ url ) { $ url = trim ( $ url ) ; $ url = strtolower ( $ url ) ; $ url = parse_url ( $ url , PHP_URL_PATH ) ; // Make sure it doesn't contain a hostname $ url = preg_replace ( '|/+|' , '/' , $ url ) ; // Remove duplicate forward slashes. if ( $ url !== '/' ) { // Remove trailing or preceeding slashes $ url = trim ( $ url , '/' ) ; } $ url = preg_replace ( '|[^' . preg_quote ( '-' ) . '\/\pL\pN\s]+|u' , '' , $ url ) ; // Remove all characters that are not a hypeh, letters, numbers, or forward slash $ url = preg_replace ( '|[' . preg_quote ( '-' ) . '\s]+|u' , '-' , $ url ) ; // Replace all hypens and whitespace by a single hyphen return $ url ; }
Remove invalid characters from a URL.

@param string $url
Remove invalid characters from a URL .