Skip to content

Centralize route event reading - #730

Closed
shawshank-redemp wants to merge 1 commit into
reticlehq:mainfrom
shawshank-redemp:main
Closed

Centralize route event reading#730
shawshank-redemp wants to merge 1 commit into
reticlehq:mainfrom
shawshank-redemp:main

Conversation

@shawshank-redemp

Copy link
Copy Markdown

What & why

Route reading was duplicated across multiple server code paths by directly reading data['pathname']. This is incorrect for hash-based routing, where the document pathname can remain / while the application's route is contained in the hash.

This change adds a shared routeOfEvent helper that derives the application route while preserving the document path, hash, search, and full navigable path. The affected call sites now use the shared helper instead of reading route fields directly.

Closes #727

How it was verified

  • Typecheck passed
  • 5,509 unit tests passed

Gates run

  • pnpm --filter @reticlehq/server typecheck
  • Server unit test suite

Signed-off-by: shawshank-redemp <212104328+shawshank-redemp@users.noreply.github.com>
@divshekhar

Copy link
Copy Markdown
Contributor

Closing in favour of #734, which landed the same change (a single routeOfEvent helper, so the six call sites stop re-indexing pathname / to / hash by hand).

The two of you arrived at the same design independently, which is a good sign the design was right. #734 went first because it also carries the hash-router case — the document pathname is / on every HashRouter page, which is the default for a packaged Electron/Tauri renderer — and that is the failure the helper exists to prevent.

Thank you for the PR; sorry it ended up on the losing side of a race.

@divshekhar divshekhar closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Route reading is duplicated six ways: centralise it behind one helper

2 participants