class ParsedURI {
        public final URI uri;
        public final String id;

        public ParsedURI(URI uri, String id) {
            this.uri = uri;
            this.id = id;
        }
    }

    public static ParsedURI parse(URI uri) {<FILL_FUNCTION_BODY>

        String protocol = uri.getScheme();
        if (protocol == null || !protocol.matches("^https?|wss?$")) {
            protocol = "https";
        }

        int port = uri.getPort();
        if (port == -1) {
            if ("http".equals(protocol) || "ws".equals(protocol)) {
                port = 80;
            } else if ("https".equals(protocol) || "wss".equals(protocol)) {
                port = 443;
            }
        }

        String path = uri.getRawPath();
        if (path == null || path.length() == 0) {
            path = "/";
        }

        String userInfo = uri.getRawUserInfo();
        String query = uri.getRawQuery();
        String fragment = uri.getRawFragment();
        String _host = uri.getHost();
        if (_host == null) {
            // might happen on some of Samsung Devices such as S4.
            _host = extractHostFromAuthorityPart(uri.getRawAuthority());
        }
        URI completeUri = URI.create(protocol + "://"
                + (userInfo != null ? userInfo + "@" : "")
                + _host
                + (port != -1 ? ":" + port : "")
                + path
                + (query != null ? "?" + query : "")
                + (fragment != null ? "#" + fragment : ""));
        String id = protocol + "://" + _host + ":" + port;

        return new ParsedURI(completeUri, id);
    
<no_super_class>