This strips a final / from URLs that have one, leaving those without unchanged.
The normalisation question
Whether URLs should end with a slash is a convention, and either answer works. What breaks things is a list containing both forms, because they compare as different strings.
Why you might strip rather than add
If the destination system, the analytics platform or the existing convention uses no trailing slash, matching that avoids a mismatch at every comparison.
Never strip the root
https://example.com/ reduced to https://example.com is a different and less correct form. The root slash is part of the address.
Try it: Remove Trailing Slash from URLs on SeoWolf's Notepad.