Make sure that blueprints with no slash is maintained when applied (#2085)
* Make sure that blueprints with no slash is maintained when applied * Remove unneeded import
This commit is contained in:
@@ -85,7 +85,11 @@ class Blueprint(BaseSanic):
|
||||
self.routes: List[Route] = []
|
||||
self.statics: List[RouteHandler] = []
|
||||
self.strict_slashes = strict_slashes
|
||||
self.url_prefix = url_prefix
|
||||
self.url_prefix = (
|
||||
url_prefix[:-1]
|
||||
if url_prefix and url_prefix.endswith("/")
|
||||
else url_prefix
|
||||
)
|
||||
self.version = version
|
||||
self.websocket_routes: List[Route] = []
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class RouteMixin:
|
||||
|
||||
# Fix case where the user did not prefix the URL with a /
|
||||
# and will probably get confused as to why it's not working
|
||||
if not uri.startswith("/"):
|
||||
if not uri.startswith("/") and (uri or hasattr(self, "router")):
|
||||
uri = "/" + uri
|
||||
|
||||
if strict_slashes is None:
|
||||
|
||||
Reference in New Issue
Block a user