Parse String to get URL SLUG

Hello.

I’m trying to parse out just the slug of a URL. The slug is the post identifier and is located at the end of the URL preceded and followed by a /.

IE…https://www.mysite.com/this-is-the-slug/

I was parsing the text by passing in a known value for the website like this…
image

But I have since found there are some of our sites that have additional structure after the primary URL that is unknown.

IE…https://www.mysite.com/recipes/this-is-the-slug/
or
https://www.mysite.com/**12-2020**/this-is-the-slug/

Can someone help me figure out how I can parse the full URL from the final / to the next / from the right in the URL so I can just pull out the SLUG and end up with /this-is-the-slug/?

Thank you in advance.
Matt

Have you tried the built-in split function, and getting the last part of the url?

Screenshot_2024-01-15_090143

Output

Screenshot_2024-01-15_090159


Links

Here are some useful links and guides to help you get started and learn more on how to use the Make platform, apps, and app modules —

General

Help Center Basics

Articles & Videos

2 Likes

@samliew - That did it! Thanks! All I needed was to then add the slashes to the beginning and the end.

image

One more question that has me a bit crosseyed.

Now that I have /this-is-the-slug/ as the SLUG. I have one site that appends .html to the end. So it looks like this-is-the-slug.html. Can you give me an example (I assume using split again) where I could trim the .html starting with the . and keep just the slug? Sorry, I have tried, but my brain isn’t able to follow the workflow of multiple splits.

image

TIA!!!

@samliew Just wanted to report back that I was able to figure it out.

In order to get http://www.mysite.com/12/2024/this-is-the-slug.html

To equal /this-is-the-slug/

I had to configure the Value like this.

image

All set. Thanks for your help in pointing me to the right place. I have to say, the documentation search in make.com is absolutely terrible and then even if you can find the right document, the actual instructions are quite lacking. Very few examples, and for someone trying to start with the system, it’s really difficult to interpret. Could use some real help.

You could use the built-in replace function:

{{ replace(variable; ".html"; emptystring) }}

3 Likes

Here are some useful links and guides to help you get started and learn more on how to use the Make platform, apps, and app modules —

General

Help Center Basics

Articles & Videos

3 Likes