feat(mapper): preserve Django include route prefixes#103
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e7dba1a17
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return prefix; | ||
| } | ||
| return normalizeDjangoRoutePath( | ||
| `${prefix.replace(/^\/+|\/+$/gu, "")}/${route.replace(/^\/+/u, "")}`, |
There was a problem hiding this comment.
Respect slashless include prefixes when composing routes
When expanding include(...) routes, this join always inserts a / between prefix and child, which mis-models valid Django patterns like path('api', include('app.urls')): Django concatenates the remaining URL directly, so child path('users/', ...) resolves under /apiusers/, not /api/users/. With the current logic, mapped feature routes can be incorrect whenever the parent include omits a trailing slash, which affects route accuracy and any downstream trust-boundary/test association tied to the generated path.
Useful? React with 👍 / 👎.
|
Addressed in 12a7be1: Django include path composition now preserves slashless path() semantics, so path(api, include(...)) maps concatenated child routes without an inserted separator. Added regression coverage for nested slashless includes. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(mapper): preserve Django include route prefixes This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
include("module.urls")child routes with their mount prefixurls.pyroutes as standalone root routesWhy
Django projects commonly split route declarations across package-level
urls.pyfiles. Previously, routes underpath("api/", include("api.urls"))could be surfaced as bare child paths such as/users/:pk/, which loses the actual public route shape.Tests
./node_modules/.bin/vitest run src/mapper.test.ts -t 'Django urls.py routes'./node_modules/.bin/vitest run src/mapper.test.ts./node_modules/.bin/tsc -p tsconfig.json --noEmit./node_modules/.bin/oxlint . --config oxlint.json./node_modules/.bin/oxfmt --check src/mappers/python.ts src/mapper.test.tsgit diff --check./node_modules/.bin/vitest run./node_modules/.bin/tsc -p tsconfig.build.json