r8-forks / webapp-improved

Automatically exported from code.google.com/p/webapp-improved
Other
0 stars 0 forks source link

PathPrefixRoute redirects when rest of route is empty but then 404s. #83

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
class HelloWorld(webapp2.RequestHandler):
    @user_util.open_access
    def get(self):
        self.response.out.write("Hello World")

application = request_handler.WSGIApplication([
    routes.PathPrefixRoute('/hello', [
        routes.RedirectRoute('',
            HelloWorld,
            strict_slash=True,
            name="hello"),
        routes.RedirectRoute('/world',
            HelloWorld,
            strict_slash=True,
            name="hello-world")
        ])
    ])

2.
Go to /hello/

What is the expected output? What do you see instead?
A redirect to /hello and Hello World being output is expected. Instead it does 
the redirect to /hello but I get a 404 then.

Using:
webapp2-2.5.2

Please provide any additional information below.
Changing the regex in webapp2_extras/routes.py PathPrefixRoute.regex like:

222c222
<             webapp2._parse_route_template(self.prefix + '<:/.*>')

---
>             webapp2._parse_route_template(self.prefix + '<:|/.*>')

would allow both /hello/ and /hello to work while still forbidding /helloworld

Original issue reported on code.google.com by ja...@khanacademy.org on 23 Aug 2013 at 4:57