- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
I want to use pathname in another variable, but first I need to remove the leading and trailing slashes. How can I do this?
Solved! Go to Solution.
Are you wanting to remove the slashes from the entire pathname? e.g. /localhost/example/author/admin/
Or do you want to remove the leading and trailing slashes of each pathname section? e.g. /example/
If it is the ladder, are you already using the pathname tokenizer extension?
Thanks
I'm trying to just remove the leading and trailing slashes. I haven't implemented the pathname tokenizer because I thought this would rip apart the whole pathname into separate pieces. Is that not the case?
Yes, that's right. The pathname tokenizer splits up the pathname into sections and stores each section in varialbes.
If you would just like to remove the leading and trailing slashes of the utag.data['dom.pathname'], you can add a Set Data Values extension in TiQ to set the new pathname variable to the following:
b['dom.pathname'].replace(/^\/|\/$/g, '');
Here is a full example:
I do not know the details of your use case so if you have any issues with this implementation, let me know the details.
Thanks!
Copyright All Rights Reserved © 2008-2023