fix(lobby): normalize host SPA deeplink path segments
All checks were successful
CI / test-and-quality (push) Successful in 2m7s
CI / test-and-quality (pull_request) Successful in 2m6s

This commit is contained in:
2026-03-01 11:25:54 +00:00
parent 84438b2880
commit 2f142aeb24
2 changed files with 14 additions and 1 deletions

View File

@@ -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, "<app-root>")
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"))

View File

@@ -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")