static function sanitizeUrl($url)
    {
        if(
            self::validateUrl($url) &&
            substr($url, -1) === '/'
        ) {
            $urlParts = parse_url($url);
            if(
                !isset($urlParts['path']) ||
                ($urlParts['path'] == '/' && !isset($urlParts['query'])) ||
                (isset($urlParts['query']) && substr($urlParts['query'], -1) === '/')
            ){
                $url = rtrim($url, '/');
            }
        }

        return $url;
    }