Skip to content

Commit

Permalink
Encode revalidateTag value fixes #61390 (#61392)
Browse files Browse the repository at this point in the history
fixes #61390

### What?

Added encodeURIComponent to encode revalidateTag value beforing
appending it to the url.

### Why?

If a tag contains special characters the tag wont be revalidated because
the special characters arent encoded.
By encoding the tag any special characters can be used.
Check out issue #61390 for further explanation

I believe this is the reason why users report the revalidateTag as
unreliable. They might be using special characters in their tags to make
sure they are unique, but when deployed to vercel and the fetch cache is
used revalidateTag fail to revalidate them.

### How?

By encoding revalidateTag with encodeURIcomponent the tag can contain
special characters.

Closes NEXT-
Fixes #61390

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
OMikkel and ijjk committed Feb 5, 2024
1 parent b44b7eb commit 6d5caca
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export default class FetchCache implements CacheHandler {

try {
const res = await fetch(
`${this.cacheEndpoint}/v1/suspense-cache/revalidate?tags=${tag}`,
`${
this.cacheEndpoint
}/v1/suspense-cache/revalidate?tags=${encodeURIComponent(tag)}`,
{
method: 'POST',
headers: this.headers,
Expand Down

0 comments on commit 6d5caca

Please sign in to comment.