public static String addParameter(final String url, final String name, final String value) {
        if (url != null) {
            val sb = new StringBuilder();
            sb.append(url);
            if (name != null) {
                if (url.indexOf("?") >= 0) {
                    sb.append("&");
                } else {
                    sb.append("?");
                }
                sb.append(name);
                sb.append("=");
                if (value != null) {
                    sb.append(urlEncode(value));
                }
            }
            return sb.toString();
        }
        return null;
    }
Add a new parameter to an url.

@param url   url
@param name  name of the parameter
@param value value of the parameter
@return the new url with the parameter appended
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java