fix(mobile): encode cold task host route

This commit is contained in:
Brennan Benson
2026-07-31 17:48:55 -07:00
parent 4a7e0d0e0f
commit 71d0023236
2 changed files with 9 additions and 6 deletions
@@ -1,6 +1,10 @@
import { describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { mobileTasksRoute, navigateToMobileTasks } from './mobile-task-navigation'
afterEach(() => {
vi.unstubAllGlobals()
})
describe('mobileTasksRoute', () => {
it('builds a concrete encoded host route', () => {
expect(mobileTasksRoute('host/1')).toBe('/h/host%2F1/tasks')
@@ -16,12 +20,11 @@ describe('mobileTasksRoute', () => {
return 1
})
navigateToMobileTasks({ push, replace }, 'host-1', 'github')
expect(push).toHaveBeenCalledWith('/h/host-1')
navigateToMobileTasks({ push, replace }, 'host/1', 'github')
expect(push).toHaveBeenCalledWith('/h/host%2F1')
expect(replace).not.toHaveBeenCalled()
nextFrame?.(0)
expect(replace).toHaveBeenCalledWith(mobileTasksRoute('host-1', 'github'))
vi.unstubAllGlobals()
expect(replace).toHaveBeenCalledWith(mobileTasksRoute('host/1', 'github'))
})
})
+1 -1
View File
@@ -21,7 +21,7 @@ export function navigateToMobileTasks(
provider?: TaskProvider
): void {
// Why: a cold nested host navigator resolves a deep push to its index route.
router.push(`/h/${hostId}`)
router.push(`/h/${encodeURIComponent(hostId)}`)
requestAnimationFrame(() => {
router.replace(mobileTasksRoute(hostId, provider))
})