Grap first part of url using javascript

Wonder if somebody can help me get some javascript running

I have a url like:

I need to put in some parameters like:

The filename can be grapped by the javascript as seen in the post below.

But I need to get the first part:

How can that be done? Or is there a better solution to obtain what I trying to do :slight_smile:

NB: Seems that all the javascript columns that I create will give the same result even though I change the javascript code. Anyone else seeing the same behavior?

Referred post:

Try this:

const bits = p1.split('/');
const last_bit = bits.pop();
return bits.join('/') + `/${p2}/${last_bit}`;

1 Like

@Krivo if you want a way to do this without JavaScript, you could use two Extract Matching Text columns to pull the URL and Filename into two separate columns, and then create a new URL (inserting your parameters) with a template.

Something like this:

Regular Expression for the first column: ^(.*)\/
Regular Expression for the second column: ^.*\/(.*)$

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.