Did a bit of quick research on the forum because I thought I’d seen a solution before. It seems like there may be another way to do this that uses the user friendly version of the URL. Here’s two articles that explain it:
- Extracting parts of the URL (Core Idea)
- User friendly URLs (Updated Approach, I believe)
Would this approach make sense for your use case?