public static SchemeAndAuthority of(@Nullable String scheme, String authority) {
        requireNonNull(authority, "authority");

        if (scheme != null) {
            scheme = ArmeriaHttpUtil.schemeValidateAndNormalize(scheme);
        }

        if (authority.startsWith("unix%3A") || authority.startsWith("unix%3a")) {
            return new SchemeAndAuthority(scheme, authority, authority, -1);
        }

        final String authorityWithoutUserInfo = removeUserInfo(authority);

        for (int i = 0; i < authorityWithoutUserInfo.length(); i++) {
            final char c = authorityWithoutUserInfo.charAt(i);
            if (c < 0x80 && RESERVED_CHARS.get(c)) {
                throw new IllegalArgumentException("The authority contains reserved character: " +
                                                   authority + " (" + c + ')');
            }
        }

        try {
            final URI uri = new URI(null, authorityWithoutUserInfo, null, null, null);
            String rawAuthority = uri.getRawAuthority();
            if (Strings.isNullOrEmpty(rawAuthority)) {
                throw new IllegalArgumentException("Invalid authority: " + authority);
            }
            rawAuthority = IDN.toASCII(rawAuthority, IDN.ALLOW_UNASSIGNED);

            final boolean isIpv6 = rawAuthority.charAt(0) == '[';
            if (isIpv6) {
                rawAuthority = removeIpv6ScopeId(rawAuthority);
            }

            final HostAndPort hostAndPort = HostAndPort.fromString(rawAuthority);
            String host = hostAndPort.getHost();
            if (isIpv6) {
                host = '[' + host + ']';
            }
            final int port = hostAndPort.getPortOrDefault(-1);

            return new SchemeAndAuthority(scheme, rawAuthority, host, port);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
Attempts to parse this URI's authority component and return {@link SchemeAndAuthority}.
The authority part may have one of the following formats (The userinfo part will be ignored.):
<ul>
  <li>{@code "unix$3A<socket file>"} for a domain socket authority </li>
  <li>{@code "<host>:<port>"} for a host endpoint </li>
  <li>{@code "<host>"}, {@code "<host>:"} for a host endpoint with no port number specified</li>
</ul>
An IPv4 or IPv6 address can be specified in lieu of a host name, e.g. {@code "127.0.0.1:8080"} and
{@code "[::1]:8080"}.

@throws IllegalArgumentException if {@code scheme} or {@code authority} do not comply with RFC 2396
core/src/main/java/com/linecorp/armeria/internal/common/SchemeAndAuthority.java