Skip to content

Commit 451a20c

Browse files
author
Lukas Holzer
committed
fix: handle non ASCII characters in cache-tag headers
1 parent a535638 commit 451a20c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/run/handlers/cache.cts

+5-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
147147
) {
148148
// pages router doesn't have cache tags headers in PAGE cache value
149149
// so we need to generate appropriate cache tags for it
150-
const cacheTags = [`_N_T_${key === '/index' ? '/' : key}`]
150+
// encode here to deal with non ASCII characters in the key
151+
152+
const cacheTags = [`_N_T_${key === '/index' ? '/' : encodeURI(key)}`]
151153
requestContext.responseCacheTags = cacheTags
152154
}
153155
}
@@ -341,7 +343,8 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
341343
if (data?.kind === 'PAGE' || data?.kind === 'PAGES') {
342344
const requestContext = getRequestContext()
343345
if (requestContext?.didPagesRouterOnDemandRevalidate) {
344-
const tag = `_N_T_${key === '/index' ? '/' : key}`
346+
// encode here to deal with non ASCII characters in the key
347+
const tag = `_N_T_${key === '/index' ? '/' : encodeURI(key)}`
345348
getLogger().debug(`Purging CDN cache for: [${tag}]`)
346349
requestContext.trackBackgroundWork(
347350
purgeCache({ tags: [tag] }).catch((error) => {

0 commit comments

Comments
 (0)