Share feedback, ideas and get community help

Updated 8 months ago

JavaScript not loading on client

At a glance

A community member has a JavaScript function that was previously working to parse the URL of the browser, but it has stopped working. The variable "location" is not being populated with any data, and there are no console errors. The community member has commented out some code from earlier experiments. Another community member suggests that the function may not be able to return anything into the Typebot flow, and recommends putting the script on the webpage and passing it through prefilled variables instead. The community members note that the issue started after a recent update, and one member has managed to reproduce the problem. A link to a GitHub commit is provided, which may be related to the issue.

Useful resources
I have the following JS in a Create Variable block that was working fine to parse the URL of the browser but it seems to have stopped working. It was working fine before. The variable "location" is not populating with anything. There are no console errors:

Create Variable block sets first result as currentURL:

Code:
-------
function parseURL() {
const windowURL = window.location.href;
const allSegments = windowURL.split('/');
const relevantSegments = allSegments.slice(4); // slice starts after third '/'
const modifiedSegments = relevantSegments.map(function(segment) {
return segment.replace(/-/g, ' ');
});
return modifiedSegments;
}

//const splitURL = parseURL();
//const currentURL = JSON.stringify(splitURL);
const currentURL = parseURL();

return currentURL;
-------

Then, in a second Create Variable block ("location"), I have:

{{={{currentURL}}[1]=}}

Any ideas why it would have stopped working?
Attachment
image.png
R
B
6 comments
Yes, I know two 'const' lines are commented out. That was from earlier experiments.
I don’t think it’s capable of returning anything into the typebot flow.
I do something similar you can put it in the script on the webpage it’s starting from, and pass it through prefilled variables
It worked perfectly until the latest update.
I managed to reproduce.
Add a reply
Sign up and join the conversation on Discord