Fix TypeError when use Blueprint.group() to group blueprint with default url_prefix, Use os.path.normpath to avoid invalid url_prefix like api//v1

This commit is contained in:
jacob
2018-09-29 18:23:16 +08:00
parent 076cf51fb2
commit bd6dbd9090
2 changed files with 41 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
import os
from collections import defaultdict, namedtuple
from sanic.constants import HTTP_METHODS
@@ -54,7 +55,10 @@ class Blueprint:
yield i
bps = []
for bp in chain(blueprints):
if bp.url_prefix is None:
bp.url_prefix = ''
bp.url_prefix = url_prefix + bp.url_prefix
bp.url_prefix = os.path.normpath(bp.url_prefix)
bps.append(bp)
return bps