parse the given URI to [domain, port, ssl, path]
436482
def ssl_domain_port_path(uri)
      uri = URI.parse(uri)
      ssl = uri.scheme == 'https'
      [ssl, uri.host, uri.port, uri.path]
    end
240726
private void parse(State state, final String uri, final int offset, final int end) {
        boolean encoded = false;
        int mark = offset;
        int path_mark = 0;

        for (int i = offset; i < end; i++) {
            char c = uri.charAt(i);

            switch (state) {
                case START: {
                    switch (c) {
                        case '/':
                            mark = i;
                            state = State.HOST_OR_PATH;
                            break;
                        case ';':
                            mark = i + 1;
                            state = State.PARAM;
                            break;
                        case '?':
                            // assume empty path (if seen at start)
                            _path = "";
                            mark = i + 1;
                            state = State.QUERY;
                            break;
                        case '#':
                            mark = i + 1;
                            state = State.FRAGMENT;
                            break;
                        case '*':
                            _path = "*";
                            state = State.ASTERISK;
                            break;

                        default:
                            mark = i;
                            if (_scheme == null)
                                state = State.SCHEME_OR_PATH;
                            else {
                                path_mark = i;
                                state = State.PATH;
                            }
                    }

                    continue;
                }

                case SCHEME_OR_PATH: {
                    switch (c) {
                        case ':':
                            // must have been a scheme
                            _scheme = uri.substring(mark, i);
                            // Start again with scheme set
                            state = State.START;
                            break;

                        case '/':
                            // must have been in a path and still are
                            state = State.PATH;
                            break;

                        case ';':
                            // must have been in a path
                            mark = i + 1;
                            state = State.PARAM;
                            break;

                        case '?':
                            // must have been in a path
                            _path = uri.substring(mark, i);
                            mark = i + 1;
                            state = State.QUERY;
                            break;

                        case '%':
                            // must have be in an encoded path
                            encoded = true;
                            state = State.PATH;
                            break;

                        case '#':
                            // must have been in a path
                            _path = uri.substring(mark, i);
                            state = State.FRAGMENT;
                            break;
                    }
                    continue;
                }

                case HOST_OR_PATH: {
                    switch (c) {
                        case '/':
                            _host = "";
                            mark = i + 1;
                            state = State.HOST;
                            break;

                        case '@':
                        case ';':
                        case '?':
                        case '#':
                            // was a path, look again
                            i--;
                            path_mark = mark;
                            state = State.PATH;
                            break;
                        default:
                            // it is a path
                            path_mark = mark;
                            state = State.PATH;
                    }
                    continue;
                }

                case HOST: {
                    switch (c) {
                        case '/':
                            _host = uri.substring(mark, i);
                            path_mark = mark = i;
                            state = State.PATH;
                            break;
                        case ':':
                            if (i > mark)
                                _host = uri.substring(mark, i);
                            mark = i + 1;
                            state = State.PORT;
                            break;
                        case '@':
                            if (_user != null)
                                throw new IllegalArgumentException("Bad authority");
                            _user = uri.substring(mark, i);
                            mark = i + 1;
                            break;

                        case '[':
                            state = State.IPV6;
                            break;
                    }
                    continue;
                }

                case IPV6: {
                    switch (c) {
                        case '/':
                            throw new IllegalArgumentException("No closing ']' for ipv6 in " + uri);
                        case ']':
                            c = uri.charAt(++i);
                            _host = uri.substring(mark, i);
                            if (c == ':') {
                                mark = i + 1;
                                state = State.PORT;
                            } else {
                                path_mark = mark = i;
                                state = State.PATH;
                            }
                            break;
                    }

                    continue;
                }

                case PORT: {
                    if (c == '@') {
                        if (_user != null)
                            throw new IllegalArgumentException("Bad authority");
                        // It wasn't a port, but a password!
                        _user = _host + ":" + uri.substring(mark, i);
                        mark = i + 1;
                        state = State.HOST;
                    } else if (c == '/') {
                        _port = TypeUtils.parseInt(uri, mark, i - mark, 10);
                        path_mark = mark = i;
                        state = State.PATH;
                    }
                    continue;
                }

                case PATH: {
                    switch (c) {
                        case ';':
                            mark = i + 1;
                            state = State.PARAM;
                            break;
                        case '?':
                            _path = uri.substring(path_mark, i);
                            mark = i + 1;
                            state = State.QUERY;
                            break;
                        case '#':
                            _path = uri.substring(path_mark, i);
                            mark = i + 1;
                            state = State.FRAGMENT;
                            break;
                        case '%':
                            encoded = true;
                            break;
                    }
                    continue;
                }

                case PARAM: {
                    switch (c) {
                        case '?':
                            _path = uri.substring(path_mark, i);
                            _param = uri.substring(mark, i);
                            mark = i + 1;
                            state = State.QUERY;
                            break;
                        case '#':
                            _path = uri.substring(path_mark, i);
                            _param = uri.substring(mark, i);
                            mark = i + 1;
                            state = State.FRAGMENT;
                            break;
                        case '/':
                            encoded = true;
                            // ignore internal params
                            state = State.PATH;
                            break;
                        case ';':
                            // multiple parameters
                            mark = i + 1;
                            break;
                    }
                    continue;
                }

                case QUERY: {
                    if (c == '#') {
                        _query = uri.substring(mark, i);
                        mark = i + 1;
                        state = State.FRAGMENT;
                    }
                    continue;
                }

                case ASTERISK: {
                    throw new IllegalArgumentException("Bad character '*'");
                }

                case FRAGMENT: {
                    _fragment = uri.substring(mark, end);
                    i = end;
                }
            }
        }


        switch (state) {
            case START:
                break;
            case SCHEME_OR_PATH:
                _path = uri.substring(mark, end);
                break;

            case HOST_OR_PATH:
                _path = uri.substring(mark, end);
                break;

            case HOST:
                if (end > mark)
                    _host = uri.substring(mark, end);
                break;

            case IPV6:
                throw new IllegalArgumentException("No closing ']' for ipv6 in " + uri);

            case PORT:
                _port = TypeUtils.parseInt(uri, mark, end - mark, 10);
                break;

            case ASTERISK:
                break;

            case FRAGMENT:
                _fragment = uri.substring(mark, end);
                break;

            case PARAM:
                _path = uri.substring(path_mark, end);
                _param = uri.substring(mark, end);
                break;

            case PATH:
                _path = uri.substring(path_mark, end);
                break;

            case QUERY:
                _query = uri.substring(mark, end);
                break;
        }

        if (!encoded) {
            if (_param == null)
                _decodedPath = _path;
            else
                _decodedPath = _path.substring(0, _path.length() - _param.length() - 1);
        }
    }
1356196
def _parse_uri(uri):
        """"""

        tokens = urlparse(uri)

        if tokens.netloc != '':
            logger.error("Invalid URI: %s", uri)
            raise ValueError("MediaFire URI format error: "
                             "host should be empty - mf:///path")

        if tokens.scheme != '' and tokens.scheme != URI_SCHEME:
            raise ValueError("MediaFire URI format error: "
                             "must start with 'mf:' or '/'")

        return posixpath.normpath(tokens.path)
193935
function (url) {
        url = _.trimStart(url);
        var pathVariables,
            p = {
                raw: url
            };

        // extract the protocol
        p.protocol = _.get(url.match(regexes.extractProtocol), GET_1);
        _.isString(p.protocol) && (url = url.substr(p.protocol.length + 3)); // remove that damn protocol from url

        // extract the host
        p.host = _.get(url.match(regexes.extractHost), GET_1);

        // if host exists there are a lot you can extract from it
        if (_.isString(p.host)) {
            url = url.substr(p.host.length); // remove host from url

            if ((p.auth = _.get(p.host.match(regexes.extractHostAuth), GET_1))) {
                p.host = p.host.substr(p.auth.length + 1); // remove auth from host
                p.auth = p.auth.split(AUTH_SEPARATOR);
                p.auth = {
                    user: p.auth[0],
                    password: p.auth[1]
                };
            }

            // extract the port from the host
            p.port = _.get(p.host.match(regexes.extractPort), GET_1);
            p.port && (p.host = p.host.substring(0, p.host.length - p.port.length - 1)); // remove port from url

            p.host = _.trim(p.host, DOMAIN_SEPARATOR).split(regexes.splitDomain); // split host by subdomains
        }

        // extract the path
        p.path = _.get(url.match(regexes.extractPath), GET_0);
        if (_.isString(p.path)) {
            url = url.substr(p.path.length);
            p.path && (p.path = p.path.replace(regexes.trimPath, MATCH_1)); // remove leading slash for valid path
            // if path is blank string, we set it to undefined, if '/' then single blank string array
            p.path = p.path ? (p.path === PATH_SEPARATOR ? [E] : p.path.split(PATH_SEPARATOR)) : undefined;
        }

        // extract the query string
        p.query = _.get(url.match(regexes.extractQuery), GET_1);
        _.isString(p.query) && ((url = url.substr(p.query.length + 1)), (p.query = QueryParam.parse(p.query)));

        // extract the hash
        p.hash = _.get(url.match(regexes.extractSearch), GET_1);

        // extract path variables
        pathVariables = _.transform(p.path, function (res, segment) {
            // check if the segment has path variable prefix followed by the variable name.
            if (_.startsWith(segment, PATH_VARIABLE_IDENTIFIER) && segment !== PATH_VARIABLE_IDENTIFIER) {
                res.push({ key: segment.slice(1) }); // remove path variable prefix.
            }
        }, []);
        p.variable = pathVariables.length ? pathVariables : undefined;

        return p;
    }
72350
private function parseUri(string $uri): array
    {
        $defaults = [
            'scheme'   => '',
            'host'     => '',
            'port'     => '',
            'user'     => '',
            'pass'     => '',
            'path'     => '',
            'query'    => '',
            'fragment' => '',
        ];

        if (0 === strpos($uri, 'file://')) {
            // parse_url botches this up
            preg_match('@file://(?P<path>[^#]*)(?P<fragment>#.*)?@', $uri, $matches);

            return array_merge($defaults, array_intersect_key($matches, $defaults));
        }

        return array_merge($defaults, array_intersect_key(parse_url($uri), $defaults));
    }
1174606
def parse_proxy(uri)
      proxy = URI.parse(uri)
      self.proxy_host = proxy.host
      self.proxy_port = proxy.port
      self.proxy_user = proxy.user
      self.proxy_password = proxy.password
    end
1286076
def _uri_split(uri):
    """"""
    scheme, netloc, path, query, fragment = _safe_urlsplit(uri)

    auth = None
    port = None

    if '@' in netloc:
        auth, netloc = netloc.split('@', 1)

    if netloc.startswith('['):
        host, port_part = netloc[1:].split(']', 1)
        if port_part.startswith(':'):
            port = port_part[1:]
    elif ':' in netloc:
        host, port = netloc.split(':', 1)
    else:
        host = netloc
    return scheme, auth, host, port, path, query, fragment
806905
def parse_url(self):
        
        self.scheme = None
        self.resource = None
        self.host = None
        self.port = None

        if self.url is None:
            return

        scheme, url = self.url.split(":", 1)
        parsed = urlsplit(url, scheme="http")
        if parsed.hostname:
            self.host = parsed.hostname
        elif '+unix' in scheme:
            self.host = 'localhost'
        else:
            raise ValueError("Invalid hostname from: %s", self.url)

        if parsed.port:
            self.port = parsed.port

        if scheme == "ws":
            if not self.port:
                self.port = 8080
        elif scheme == "wss":
            if not self.port:
                self.port = 443
        elif scheme in ('ws+unix', 'wss+unix'):
            pass
        else:
            raise ValueError("Invalid scheme: %s" % scheme)

        if parsed.path:
            resource = parsed.path
        else:
            resource = "/"

        if '+unix' in scheme:
            self.unix_socket_path = resource
            resource = '/'

        if parsed.query:
            resource += "?" + parsed.query

        self.scheme = scheme
        self.resource = resource
652718
def from_uri(cls, uri, socket_timeout=None, auto_decode=False):
        
        parts = six.moves.urllib.parse.urlparse(uri)
        if parts.scheme.lower() not in ('beanstalk', 'beanstalkd'):
            raise ValueError('Invalid scheme %s' % parts.scheme)
        ipv6_md = re.match(r'^\[([0-9a-fA-F:]+)\](:[0-9]+)?$', parts.netloc)
        if ipv6_md:
            host = ipv6_md.group(1)
            port = ipv6_md.group(2) or '11300'
            port = port.lstrip(':')
        elif ':' in parts.netloc:
            host, port = parts.netloc.rsplit(':', 1)
        else:
            host = parts.netloc
            port = 11300
        port = int(port)
        return cls(host, port, socket_timeout=socket_timeout, auto_decode=auto_decode)
531261
def parse_uri(uri: str) -> WebSocketURI:
    
    parsed = urllib.parse.urlparse(uri)
    try:
        assert parsed.scheme in ["ws", "wss"]
        assert parsed.params == ""
        assert parsed.fragment == ""
        assert parsed.hostname is not None
    except AssertionError as exc:
        raise InvalidURI(uri) from exc

    secure = parsed.scheme == "wss"
    host = parsed.hostname
    port = parsed.port or (443 if secure else 80)
    resource_name = parsed.path or "/"
    if parsed.query:
        resource_name += "?" + parsed.query
    user_info = None
    if parsed.username or parsed.password:
        user_info = (parsed.username, parsed.password)
    return WebSocketURI(secure, host, port, resource_name, user_info)
708210
def urlparse(uri):
    """"""
    scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
    return (
        parse.unquote(scheme),
        parse.unquote(netloc),
        parse.unquote(path),
        parse.unquote(params),
        parse.unquote(query),
        parse.unquote(fragment)
    )
353536
def parse_uri(uri_string):
    
    parts = urlparse.urlparse(uri_string)
    uri = Uri()
    if parts[0]:
      uri.scheme = parts[0]
    if parts[1]:
      host_parts = parts[1].split(':')
      if host_parts[0]:
        uri.host = host_parts[0]
      if len(host_parts) > 1:
        uri.port = int(host_parts[1])
    if parts[2]:
      uri.path = parts[2]
    if parts[4]:
      param_pairs = parts[4].split('&')
      for pair in param_pairs:
        pair_parts = pair.split('=')
        if len(pair_parts) > 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = (
              urllib.unquote_plus(pair_parts[1]))
        elif len(pair_parts) == 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = None
    return uri
364760
def parse_email_url(url):
    """"""

    conf = {}

    url = urlparse.urlparse(url)

    # Remove query strings
    path = url.path[1:]
    path = path.split('?', 2)[0]

    # Update with environment configuration
    conf.update({
        'EMAIL_FILE_PATH': path,
        'EMAIL_HOST_USER': url.username,
        'EMAIL_HOST_PASSWORD': url.password,
        'EMAIL_HOST': url.hostname,
        'EMAIL_PORT': url.port,
    })

    if url.scheme in EMAIL_SCHEMES:
        conf['EMAIL_BACKEND'] = EMAIL_SCHEMES[url.scheme]

    if url.scheme == 'smtps':
        conf['EMAIL_USE_TLS'] = True
    else:
        conf['EMAIL_USE_TLS'] = False

    return conf
1328692
def _get_url(ssl, url, port, path):
    '''
    
    '''
    if ssl:
        return 'https://{0}:{1}/management/domain/{2}'.format(url, port, path)
    else:
        return 'http://{0}:{1}/management/domain/{2}'.format(url, port, path)
216963
def simple_parse_uri(request)
			# values = request.params
      simple_parse(request.path).each do |key, value|
          request.env[key.to_s] = value ? value : ''
        request.update_param(key.to_s, CGI.unescape(value.to_s))
      end
    end
479013
function parseUri(uri) {
  if (uri instanceof Array) {
    uri = eut(uri[0], uri[1]);
  }

  return baseUrl + uri;
}
913849
def parse(uri)
      # Legacy parsing of URI configuration; does not follow usual
      # AMQP vhost encoding but used regular URL path
      uri = ::URI.parse(uri)

      config = {}
      config[:user]  ||= uri.user     if uri.user
      config[:pass]  ||= uri.password if uri.password
      config[:host]  ||= uri.host     if uri.host
      config[:port]  ||= uri.port     if uri.port
      config[:vhost] ||= uri.path     unless uri.path.empty?
      config[:ssl]   ||= uri.scheme.casecmp('amqps').zero?

      config
    end