Skip to content

Commit

Permalink
fix: filter out empty tags
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Dec 19, 2024
1 parent 782a106 commit f112f29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/run/handlers/cache.cts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f112f29

Please sign in to comment.