Add re.sub for blueprint add_url_rule handler, prevent '/a//b/'(blueprint.url_prefix='/a/' and the route is '/b/') happened.

This commit is contained in:
zcchen 2018-02-12 18:38:54 +08:00 committed by David Lord
parent f808c20139
commit 0887245bfd
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8

View file

@ -10,6 +10,7 @@
:license: BSD, see LICENSE for more details.
"""
import re
from functools import update_wrapper
from .helpers import _PackageBoundObject, _endpoint_from_view_func
@ -67,6 +68,7 @@ class BlueprintSetupState(object):
"""
if self.url_prefix:
rule = self.url_prefix + rule
rule = re.sub('/+', '/', rule)
options.setdefault('subdomain', self.subdomain)
if endpoint is None:
endpoint = _endpoint_from_view_func(view_func)