request-path.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * Canonical HTTP path for gateway → canister proxy. |
| 3 | * Under app.use('/api/v1', handler), Express sets req.path to the suffix (e.g. /notes); |
| 4 | * serverless-http / Netlify may leave req.originalUrl inconsistent. Prefer baseUrl + path. |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * @param {import('express').Request} req |
| 9 | * @returns {string} pathname only (no query) |
| 10 | */ |
| 11 | export function effectiveRequestPath(req) { |
| 12 | const combined = (req.baseUrl || '') + (req.path || ''); |
| 13 | const noQuery = combined.split('?')[0]; |
| 14 | if (noQuery.startsWith('/api/v1')) return noQuery; |
| 15 | const raw = (req.originalUrl || req.url || '/').split('?')[0]; |
| 16 | return raw; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Path + query for upstream canister (preserve search from originalUrl). |
| 21 | * @param {import('express').Request} req |
| 22 | */ |
| 23 | export function upstreamPathAndQuery(req) { |
| 24 | const raw = req.originalUrl || req.url || '/'; |
| 25 | const q = raw.indexOf('?'); |
| 26 | const search = q >= 0 ? raw.slice(q) : ''; |
| 27 | return effectiveRequestPath(req) + search; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @param {import('express').Request} req |
| 32 | */ |
| 33 | export function pathPartNoQuery(req) { |
| 34 | return effectiveRequestPath(req); |
| 35 | } |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago