char* oidc_get_current_url(request_rec *r) {
	char *url = NULL, *path = NULL;
	apr_uri_t uri;

	path = r->uri;

	/* check if we're dealing with a forward proxying secenario i.e. a non-relative URL */
	if ((path) && (path[0] != '/')) {
		memset(&uri, 0, sizeof(apr_uri_t));
		if (apr_uri_parse(r->pool, r->uri, &uri) == APR_SUCCESS)
			path = apr_pstrcat(r->pool, uri.path,
					(r->args != NULL && *r->args != '\0' ? "?" : ""), r->args,
					NULL);
		else
			oidc_warn(r, "apr_uri_parse failed on non-relative URL: %s",
					r->uri);
	} else {
		/* make sure we retain URL-encoded characters original URL that we send the user back to */
		path = r->unparsed_uri;
	}

	url = apr_pstrcat(r->pool, oidc_get_current_url_base(r), path, NULL);

	oidc_debug(r, "current URL '%s'", url);

	return url;
}
char* oidc_get_current_url(request_rec *r) {
	char *url = NULL, *path = NULL;
	apr_uri_t uri;

	path = r->uri;

	 
	if ((path) && (path[0] != '/')) {
		memset(&uri, 0, sizeof(apr_uri_t));
		if (apr_uri_parse(r->pool, r->uri, &uri) == APR_SUCCESS)
			path = apr_pstrcat(r->pool, uri.path,
					(r->args != NULL && *r->args != '\0' ? "?" : ""), r->args,
					NULL);
		else
			oidc_warn(r, "apr_uri_parse failed on non-relative URL: %s",
					r->uri);
	} else {
		 
		path = r->unparsed_uri;
	}

	url = apr_pstrcat(r->pool, oidc_get_current_url_base(r), path, NULL);

	oidc_debug(r, "current URL '%s'", url);

	return url;
}