In a web handler routes configuration I have the following Regex:
('/post/(\w+)/.*', foo.app.WebHandlerFooClass)
this regex matches these kind of urls:
/post/HUIHUIGgS823SHUIH/this-is-the-slug/post/HUIHUIGgS823SHUIH/
passing the correct HUIHUIGgS823SHUIH Id parameter to the web handler matched by the (\w+) group.
How could I modify the above Regex to match also this url?
/post/HUIHUIGgS823SHUIH
The handler is coded to accept just one parameter, the base64 Id, so there should be just one group in the Regex that matches the Id.
So, these are the urls that should be matched:
/post/HUIHUIGgS823SHUIH/this-is-the-slug/post/HUIHUIGgS823SHUIH//post/HUIHUIGgS823SHUIH<– Hey, I wanna this too
This matches the following.
/post/HUIHUIGgS823SHUIH/this-is-the-slug/post/HUIHUIGgS823SHUIH/this-is-the-slug//post/HUIHUIGgS823SHUIH//post/HUIHUIGgS823SHUIHI think this is a better implementation because it captures only the pieces you want, e.g. the slug doesn’t capture a trailing
/. However, your spec is still slightly unclear to me, so this may not be your intention.