fix(route): match page routes case-insensitively like React Router
RA
1d ago+20+20+01234567890123456789-1-1-0123456789
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?
Description
React Router matches route paths case-insensitively by default, so /About renders the page registered at /about. The backend router in reflex/route.py compiled its route regexes case-sensitively and returned no route for that URL. As a result, the page's on_load events did not run, router.page.path was /404, and the production static server answered the SPA fallback with a 404 status.
This change compiles the route regexes with re.IGNORECASE, matching the frontend. Route names are restricted to ASCII letters, digits, _ and -, so the flag has no Unicode side effects.
Testing
- New
test_get_router_ignores_caseintests/units/test_route.pyfails on main (4 failed) and passes with the change. uv run pytest tests/units --ignore=tests/units/reflex_cli: 12201 passed, 67 skipped.uv run ruff check,uv run ruff format --checkanduv run pyrightare clean on the changed files.
Closes #7598