@samitouri / QOSami-HFS / commits / a84afc20

small optimization

Massimo Melina committed Aug 2, 2023 at 15:57 UTC a84afc200a0252740c68097b239b2c6ca4fc6b15
1 file changed +7 -6
src/apiMiddleware.ts
+7 -6
@@ -35,12 +35,13 @@ export function apiMiddleware(apis: ApiHandlers) : Koa.Middleware {
35 // we don't rely on SameSite cookie option because it's https-only
36 let res
37 try {
38 - for (const [k,v] of Object.entries(params))
39 - if (k.startsWith('uri'))
40 - if (typeof v === 'string')
41 - fixUri(params, k)
42 - else if (typeof (v as any)?.[0] === 'string')
43 - (v as string[]).forEach((x,i) => fixUri(v,i))
38 + if (ctx.state.revProxyPath)
39 + for (const [k,v] of Object.entries(params))
40 + if (k.startsWith('uri'))
41 + if (typeof v === 'string')
42 + fixUri(params, k)
43 + else if (typeof (v as any)?.[0] === 'string')
44 + (v as string[]).forEach((x,i) => fixUri(v,i))
45 res = csrf && csrf !== params.csrf ? new ApiError(HTTP_UNAUTHORIZED, 'csrf')
46 : await apiFun(params || {}, ctx)
47