diff --git a/lobby/tests.py b/lobby/tests.py index d7324c6..453da59 100644 --- a/lobby/tests.py +++ b/lobby/tests.py @@ -998,6 +998,17 @@ class UiScreenTests(TestCase): self.assertContains(response, "data-wpp-shell-route=\"/host/guess/round-1\"") self.assertContains(response, "data-wpp-shell-kind=\"host\"") + @override_settings(WPP_SPA_ENABLED=True) + def test_host_screen_deeplink_normalizes_redundant_slashes_when_feature_flag_enabled(self): + self.client.login(username="host_ui", password="secret123") + + response = self.client.get("/lobby/ui/host//guess///round-1//") + + self.assertEqual(response.status_code, 200) + self.assertContains(response, "") + self.assertContains(response, "data-wpp-shell-route=\"/host/guess/round-1\"") + self.assertContains(response, "data-wpp-shell-kind=\"host\"") + @override_settings(WPP_SPA_ENABLED=True) def test_player_screen_can_render_angular_shell_when_feature_flag_enabled(self): response = self.client.get(reverse("lobby:player_screen")) diff --git a/lobby/ui_views.py b/lobby/ui_views.py index 65a6137..c015cd9 100644 --- a/lobby/ui_views.py +++ b/lobby/ui_views.py @@ -22,7 +22,9 @@ def host_screen(request, spa_path=None): if settings.WPP_SPA_ENABLED: host_route = "/host" if spa_path: - host_route = f"/host/{spa_path.strip('/')}" + normalized_spa_path = "/".join(segment for segment in spa_path.split("/") if segment) + if normalized_spa_path: + host_route = f"/host/{normalized_spa_path}" return _render_spa_shell(request, host_route, "host") categories = Category.objects.filter(is_active=True).order_by("name")