From 618493a954625cb04a5323e2cec2b5cf2bc8583e Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Sun, 26 May 2024 23:20:39 +0200 Subject: [PATCH] Fix PluginWebApp base path handling 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. Fix #239 --- maubot/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maubot/server.py b/maubot/server.py index 097fe5b..dd1101e 100644 --- a/maubot/server.py +++ b/maubot/server.py @@ -64,14 +64,14 @@ class MaubotServer: if request.path.startswith(path): request = request.clone( 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) ) return await app.handle(request) return web.Response(status=404) 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 try: return self.plugin_routes[subpath], url @@ -82,7 +82,7 @@ class MaubotServer: def remove_instance_webapp(self, instance_id: str) -> None: 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() except KeyError: return