fix: ctx.path is the right property for our use

Massimo Melina committed Dec 14, 2021 at 15:46 UTC f207c9ea0b781662708c9a0192b03ec85022fefc
2 files changed +3 -3
src/frontend.ts
+1 -1
@@ -20,7 +20,7 @@ function serveStaticFrontend() : Koa.Middleware {
20 console.debug('fronted: static')
21 const cache = new MemoMap()
22 return async (ctx, next) => {
23 - let file = ctx.url
23 + let file = ctx.path
24 if (file.startsWith('/'))
25 file = file.slice(1)
26 ctx.body = await cache.getOrSet(file, () =>
src/index.ts
+2 -2
@@ -27,9 +27,9 @@ const serveFrontendPrefixed = mount(FRONTEND_URI.slice(0,-1), serveFrontend)
27 srv.use(async (ctx, next) => {
28 if (ctx.method !== 'GET')
29 return await next()
30 - if (ctx.url.endsWith('/'))
30 + if (ctx.path.endsWith('/'))
31 return await serveFrontend(ctx,next)
32 - if (ctx.url.startsWith(FRONTEND_URI))
32 + if (ctx.path.startsWith(FRONTEND_URI))
33 return await serveFrontendPrefixed(ctx,next)
34 await serveFiles(ctx,next)
35 })