public static function encodeUri($uri)
    {
        $uri = self::removeSchemeFromUri($uri, $scheme);
        $uri = rawurlencode($uri);

        // Decode slashes
        $uri = str_replace("%2F", "/", $uri);

        return $scheme . $uri;
    }