Encode revalidateTag value fixes #61390 (#61392)

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>
This commit is contained in:
OMikkel 2024-02-05 01:17:46 +01:00 committed by GitHub
parent b44b7ebe35
commit 6d5cacad6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,