From f112f291b20e9472542660937cc14bd459e8ef1d Mon Sep 17 00:00:00 2001 From: pieh Date: Thu, 19 Dec 2024 17:36:24 +0100 Subject: [PATCH] fix: filter out empty tags --- src/run/handlers/cache.cts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/run/handlers/cache.cts b/src/run/handlers/cache.cts index 4bee5bb30..c00a4d5e1 100644 --- a/src/run/handlers/cache.cts +++ b/src/run/handlers/cache.cts @@ -348,7 +348,7 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { if (requestContext?.didPagesRouterOnDemandRevalidate) { // encode here to deal with non ASCII characters in the key const tag = `_N_T_${key === '/index' ? '/' : encodeURI(key)}` - const tags = tag.split(/,|%2c/gi) + const tags = tag.split(/,|%2c/gi).filter(Boolean) if (tags.length === 0) { return @@ -384,9 +384,9 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { private async doRevalidateTag(tagOrTags: string | string[], ...args: any) { getLogger().withFields({ tagOrTags, args }).debug('NetlifyCacheHandler.revalidateTag') - const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]).flatMap((tag) => - tag.split(/,|%2c/gi), - ) + const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]) + .flatMap((tag) => tag.split(/,|%2c/gi)) + .filter(Boolean) if (tags.length === 0) { return