mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 19:21:15 -05:00
FOR-201 fix hqUrl in feedback and pmf widget to work with trailing slash
This commit is contained in:
@@ -226,6 +226,10 @@ function changeType(e: Event) {
|
||||
}
|
||||
}
|
||||
|
||||
const stripLastBackslash = (url: string) => {
|
||||
return url.endsWith("/") ? url.slice(0, -1) : url;
|
||||
};
|
||||
|
||||
function submit(e: Event) {
|
||||
e.preventDefault();
|
||||
const target = e.target as HTMLFormElement;
|
||||
@@ -253,11 +257,16 @@ function submit(e: Event) {
|
||||
finished: true,
|
||||
};
|
||||
|
||||
fetch(`${config.hqUrl || "https://xm.formbricks.com"}/api/capture/forms/${config.formId}/submissions`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
fetch(
|
||||
`${stripLastBackslash(config.hqUrl || "https://xm.formbricks.com")}/api/capture/forms/${
|
||||
config.formId
|
||||
}/submissions`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
containerElement.setAttribute("data-success", "");
|
||||
const feedbackType = containerElement.getAttribute("data-feedback-type");
|
||||
|
||||
@@ -161,20 +161,27 @@ async function submitElement(name?: string, value?: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const stripLastBackslash = (url: string) => {
|
||||
return url.endsWith("/") ? url.slice(0, -1) : url;
|
||||
};
|
||||
|
||||
async function createSubmission(submission: any) {
|
||||
if (!config.formId) {
|
||||
throw new Error("Missing formId");
|
||||
}
|
||||
const response = await fetch(`${config.formbricksUrl}/api/capture/forms/${config.formId}/submissions`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer: config.customer,
|
||||
data: submission,
|
||||
}),
|
||||
});
|
||||
const response = await fetch(
|
||||
`${stripLastBackslash(config.formbricksUrl)}/api/capture/forms/${config.formId}/submissions`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
customer: config.customer,
|
||||
data: submission,
|
||||
}),
|
||||
}
|
||||
);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
@@ -189,7 +196,9 @@ async function updateSubmission(submissionId: string, submission: any, finished:
|
||||
body["finished"] = true;
|
||||
}
|
||||
const response = await fetch(
|
||||
`${config.formbricksUrl}/api/capture/forms/${config.formId}/submissions/${submissionId}`,
|
||||
`${stripLastBackslash(config.formbricksUrl)}/api/capture/forms/${
|
||||
config.formId
|
||||
}/submissions/${submissionId}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
@@ -205,9 +214,12 @@ async function sendWarmupRequest() {
|
||||
if (!config.formId) {
|
||||
throw new Error("Missing formId");
|
||||
}
|
||||
const response = await fetch(`${config.formbricksUrl}/api/capture/forms/${config.formId}/submissions`, {
|
||||
method: "OPTIONS",
|
||||
});
|
||||
const response = await fetch(
|
||||
`${stripLastBackslash(config.formbricksUrl)}/api/capture/forms/${config.formId}/submissions`,
|
||||
{
|
||||
method: "OPTIONS",
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
|
||||
const isLink = typeof props.href !== "undefined";
|
||||
const elementType = isLink ? "span" : "button";
|
||||
|
||||
const element = React.createElement(
|
||||
const element: any = React.createElement(
|
||||
elementType,
|
||||
{
|
||||
...passThroughProps,
|
||||
|
||||
Reference in New Issue
Block a user