protected String appendParameters(ExternalContext externalContext, String url, Map<String, List<String>> parameters) {
        StringBuilder urlBuilder = new StringBuilder(url);
        boolean existingParameters = url.contains("?");

        for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
            String name = entry.getKey();

            for (String value : entry.getValue()) {
                if (LangUtils.isEmpty(name) && LangUtils.isEmpty(value)) {
                    continue;
                }

                if (url.contains(name + "=" + value)
                        || url.contains(name + "=" + encodeURLParameterValue(value, externalContext))) {
                    continue;
                }

                if (!existingParameters) {
                    urlBuilder.append("?");
                    existingParameters = true;
                }
                else {
                    urlBuilder.append("&");
                }

                urlBuilder.append(encodeURLParameterValue(name, externalContext))
                    .append("=")
                    .append(encodeURLParameterValue(value, externalContext));
            }
        }

        return urlBuilder.toString();
    }
Constructs the URL for the initialRedirect, which equals the current requested URL + the window id candidate.
We cant use
{@link jakarta.faces.application.ViewHandler#getBookmarkableURL(jakarta.faces.context.FacesContext, java.lang.String, java.util.Map, boolean)}
as the ViewRoot isn't available yet in the {@link FacesContext}.
Same applies for {@link ExternalContext#encodeRedirectURL(java.lang.String, java.util.Map)}.

@param context The {@link FacesContext}.
@return The initial-redirect URL.
primefaces/src/main/java/org/primefaces/clientwindow/PrimeClientWindow.java