GoogleCloudPlatform / webapp2

webapp2 is a framework for Google App Engine
https://webapp2.readthedocs.org
Other
141 stars 63 forks source link

Route instances unexpectedly force ^ and $ onto template expression #61

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What is the expected output? What do you see instead?

Example route:
  (r'^/widget/(?P<widget_id>\w+)/?', handlers.Widget)

This  *should* work for the following URLs, and happily ignore the slugified 
title, using a single Route definition:
/widget/123xyz
/widget/123xyz/
/widget/123xyz/slugified_widget_title
/widget/123xyz/slugified_widget_title/

Because all Route instances force-append a $ onto the template expression, it 
breaks this expected behavior. This doesn't appear to be documented, I had to 
read the source to determine the problem. (Disclaimer: Maybe I just missed it 
in the docs, if it does exist?)

Instead, the URLs containing the slugified titles are not matched and result in 
a 404. This forces me to either 1) write a more complex expression, or 2) write 
duplicate routes.

What version of the product are you using? On what operating system?
v2.5.1

Please provide any additional information below.

Original issue reported on code.google.com by erichigg...@gmail.com on 3 Aug 2012 at 1:14