protected UriComponents normalize(final String resource) {
        val builder = UriComponentsBuilder.newInstance();

        val resourcePattern = RegexUtils.createPattern(properties.getResourcePattern());
        val matcher = resourcePattern.matcher(resource);
        if (!matcher.matches()) {
            LOGGER.error("Unable to match the resource [{}] against pattern [{}] for normalization", resource, matcher.pattern().pattern());
            return null;
        }

        builder.scheme(matcher.group(PATTERN_GROUP_INDEX_SCHEME));
        builder.userInfo(matcher.group(PATTERN_GROUP_INDEX_USERINFO));
        builder.host(matcher.group(PATTERN_GROUP_INDEX_HOST));
        val port = matcher.group(PATTERN_GROUP_INDEX_PORT);
        if (!StringUtils.isBlank(port)) {
            builder.port(Integer.parseInt(port));
        }
        builder.path(matcher.group(PATTERN_GROUP_INDEX_PATH));
        builder.query(matcher.group(PATTERN_GROUP_INDEX_QUERY));
        builder.fragment(matcher.group(PATTERN_GROUP_INDEX_FRAGMENT));

        val currentBuilder = builder.build();

        if (StringUtils.isBlank(currentBuilder.getScheme())) {
            if (StringUtils.isNotBlank(currentBuilder.getUserInfo()) && StringUtils.isBlank(currentBuilder.getPath())
                && StringUtils.isBlank(currentBuilder.getQuery()) && currentBuilder.getPort() < 0) {
                builder.scheme("acct");
            } else {
                builder.scheme("https");
            }
        }
        builder.fragment(null);
        return builder.build();
    }
This is {@link OidcDefaultWebFingerDiscoveryService}.

@author Misagh Moayyed
@since 6.1.0
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/discovery/webfinger/OidcDefaultWebFingerDiscoveryService.java