private static URI normalizePortNumbersInUri(final URI uri) throws URISyntaxException {
        var port = uri.getPort();
        val scheme = uri.getScheme();

        if (SCHEME_HTTP.equals(scheme) && port == DEFAULT_HTTP_PORT) {
            port = -1;
        }
        if (SCHEME_HTTPS.equals(scheme) && port == DEFAULT_HTTPS_PORT) {
            port = -1;
        }

        val result = new URI(scheme, uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment());
        return result;
    }
Normalizes a URI. If it contains the default port for the used scheme, the method replaces the port with "default".

@param uri
           The URI to normalize.

@return A normalized URI.

@throws URISyntaxException
            If a URI cannot be created because of wrong syntax.
pac4j-saml/src/main/java/org/pac4j/saml/util/SAML2Utils.java