Skip to content

🎥 Make videos programmatically with React

staticfile encoding

Jonny Burger4278051d7712
diff --git a/packages/docs/docs/4-0-migration.md b/packages/docs/docs/4-0-migration.md
index 3014fa5dc2..404b22f828 100644
--- a/packages/docs/docs/4-0-migration.md
+++ b/packages/docs/docs/4-0-migration.md
@@ -172,6 +172,20 @@ Previously you were able to set a value for `crf` when rendering a GIF. This was
## `staticFile()` URI-unsafe characters handling
-Up to now, [`staticFile()`](/docs/staticfile) did not handle URI-unsafe characters contained in the provided path. This could in some specific cases lead to problems, which forced users to encode paths containing unsafe characters by themselves.
+Previously, [`staticFile()`](/docs/staticfile) did not handle URI-unsafe characters contained in the provided path:
-Now, `staticFile()` checks for aforementioned characters and encodes them if contained in the path. If you encoded the path by yourself until now, make sure to drop your encoding before passing the path into `staticFile()` to avoid double encoding.
+```tsx title="Before v4"
+staticFile("my-image#portrait.png"); //output: "my-image#portrait.png"
+```
+
+This could lead to problems, when unsafe characters such as `#`, `?` and `&` were part of the filename.
+
+Now, [`staticFile()`](/docs/staticfile) encodes the filename using `encodeURIComponent`:
+
+```tsx title="Since v4.0.0"
+staticFile("my-image#portrait.png"); // "my-image%23portrait.png"
+```
+
+**How to upgrade:**
+
+If you encoded the path by yourself until now, don't do so anymore to avoid double encoding.
diff --git a/packages/docs/docs/staticfile.md b/packages/docs/docs/staticfile.md
index e75ed3e0cb..0aa1d75154 100644
--- a/packages/docs/docs/staticfile.md
+++ b/packages/docs/docs/staticfile.md
@@ -77,14 +77,14 @@ Before `v4.0`, `staticFile()` did not handle URI-unsafe characters contained in
### Example
```tsx title="Before v4"
-staticFile("/my-image#portrait.png"); //output: "/my-image#portrait.png"
+staticFile("my-image#portrait.png"); //output: "/my-image#portrait.png"
```
If this URL is passed to a component accepting an URL, the part after `#` will be left out, leading
to an error because the file can't be found.
```tsx title="Since v4.0.0"
-const url = staticFile("/my-image#portrait.png"); // "/my-image%23portrait.png"
+staticFile("my-image#portrait.png"); // "/my-image%23portrait.png"
```
The image will now be loaded properly, however, you must avoid to encode the filename yourself.