Skip to content

Commit

Permalink
fix(cache): normalize path keys for defineCachedEventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 12, 2022
1 parent 1d4328c commit 97625ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runtime/cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { hash } from 'ohash'
import { handleCacheHeaders, defineEventHandler, createEvent, EventHandler } from 'h3'
import type { H3Event } from 'h3'
import { parseURL } from 'ufo'
import { useStorage } from '#internal/nitro'

export interface CacheEntry<T=any> {
Expand Down Expand Up @@ -108,7 +109,7 @@ export function defineCachedEventHandler <T=any> (
const _opts: CachifyOptions<ResponseCacheEntry<T>> = {
...opts,
getKey: (event) => {
return event.req.originalUrl || event.req.url
return decodeURI(parseURL(event.req.originalUrl || event.req.url).pathname).replace(/\/$/, '/index')
},
group: opts.group || 'nitro/handlers',
integrity: [
Expand Down

0 comments on commit 97625ec

Please sign in to comment.