Ensure request uri with trailing slash

When request uri matching with base_url in PrefixRedirectHandler,
it's better to ensure uri with tariling slash. That's will avoid
redirecting /foobar to /foobar/hub/foobar.
This commit is contained in:
Chaolei Li
2018-07-27 17:17:26 +08:00
parent a2f003ed31
commit ab02f9c568

View File

@@ -901,6 +901,11 @@ class PrefixRedirectHandler(BaseHandler):
""" """
def get(self): def get(self):
uri = self.request.uri uri = self.request.uri
# Since self.base_url will end with trailing slash.
# Ensure uri will end with trailing slash when matching
# with self.base_url.
if not uri.endswith('/'):
uri += '/'
if uri.startswith(self.base_url): if uri.startswith(self.base_url):
path = self.request.uri[len(self.base_url):] path = self.request.uri[len(self.base_url):]
else: else: