Fix PluginWebApp base path handling (#240)
Previously, the webapp handler would match without respect to the trailing slash, e.g. matching "foo" for "foo2". This behavior is changed to respect the trailing slash. Fixes #239
This commit is contained in:
parent
c218c8cf61
commit
65be63fdd2
@ -64,14 +64,14 @@ class MaubotServer:
|
|||||||
if request.path.startswith(path):
|
if request.path.startswith(path):
|
||||||
request = request.clone(
|
request = request.clone(
|
||||||
rel_url=request.rel_url.with_path(
|
rel_url=request.rel_url.with_path(
|
||||||
request.rel_url.path[len(path) :]
|
request.rel_url.path[len(path) - 1 :]
|
||||||
).with_query(request.query_string)
|
).with_query(request.query_string)
|
||||||
)
|
)
|
||||||
return await app.handle(request)
|
return await app.handle(request)
|
||||||
return web.Response(status=404)
|
return web.Response(status=404)
|
||||||
|
|
||||||
def get_instance_subapp(self, instance_id: str) -> tuple[PluginWebApp, str]:
|
def get_instance_subapp(self, instance_id: str) -> tuple[PluginWebApp, str]:
|
||||||
subpath = self.config["server.plugin_base_path"] + instance_id
|
subpath = self.config["server.plugin_base_path"] + instance_id + "/"
|
||||||
url = self.config["server.public_url"] + subpath
|
url = self.config["server.public_url"] + subpath
|
||||||
try:
|
try:
|
||||||
return self.plugin_routes[subpath], url
|
return self.plugin_routes[subpath], url
|
||||||
@ -82,7 +82,7 @@ class MaubotServer:
|
|||||||
|
|
||||||
def remove_instance_webapp(self, instance_id: str) -> None:
|
def remove_instance_webapp(self, instance_id: str) -> None:
|
||||||
try:
|
try:
|
||||||
subpath = self.config["server.plugin_base_path"] + instance_id
|
subpath = self.config["server.plugin_base_path"] + instance_id + "/"
|
||||||
self.plugin_routes.pop(subpath).clear()
|
self.plugin_routes.pop(subpath).clear()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user