Background: I’m trying to remove the tracking part of a shortened URL by using n8n. For example: A shortened link like abc.dx/aaaa will be revealed through HTTP Request, and will be come abcde.com/aaaaa?utm=trackinglink&ad-goes-here&other-tracking. I want to remove the tracking part using Regex in IF function.
and the HTTP request is there to get the page using the same regex option so you can see how you could use it in a normal node.
The actual magic is performed by adding .match(/^[^?]+/) to the end of the input variable, I think where you were going wrong was you thought the If Node sets a variable which is not what an If node or an If statement in programming is for. You would use the If node to see if something matches a certain pattern it doesn’t do any clever extraction you would normally need to handle that after.
Hopefully this helps and gets you on your way to automating your task
Looking at that if you want the rest of the URL as well you could try using a split on the url= but you have a few URLs there so it might be worth adding an Items List node first and split out URL then add your set node or you could use a code node and do it in a loop.