🎥 Make videos programmatically with React
slashes no longer get encoded
Patric Salvisbergc3bf59939e07
diff --git a/packages/core/src/static-file.ts b/packages/core/src/static-file.tsindex 11dd548976..98ebbeba64 100644--- a/packages/core/src/static-file.ts+++ b/packages/core/src/static-file.ts@@ -67,6 +67,16 @@ const inner = (path: string): string => {return `/${trimLeadingSlash(path)}`;};+const encodeBySplitting = (path: string): string => {+ const splitBySlash = path.split('/');++ const encodedArray = splitBySlash.map((element) => {+ return encodeURIComponent(element);+ });+ const merged = encodedArray.join('/');+ return merged;+};+/*** @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.* @see [Documentation](https://www.remotion.dev/docs/staticfile)@@ -113,7 +123,8 @@ export const staticFile = (path: string) => {);}- const preparsed = inner(encodeURIComponent(path));+ const preprocessed = encodeBySplitting(path);+ const preparsed = inner(preprocessed);if (!preparsed.startsWith('/')) {return `/${preparsed}`;diff --git a/packages/core/src/test/static-file-safe-uri.test.ts b/packages/core/src/test/static-file-safe-uri.test.tsindex 82ed87a4da..241628f01e 100644--- a/packages/core/src/test/static-file-safe-uri.test.ts+++ b/packages/core/src/test/static-file-safe-uri.test.ts@@ -3,10 +3,20 @@ import {staticFile} from '../static-file.js';test('staticFile() should convert # into %23', () => {const unsafeName = 'test/example#music';- expect(staticFile(unsafeName)).toBe('/test%2Fexample%23music');+ expect(staticFile(unsafeName)).toBe('/test/example%23music');});test('staticFile() passing already encoded path should give warning', () => {const unsafeName = '/test%2Fexample%23music';- expect(staticFile(unsafeName)).toBe('/%2Ftest%252Fexample%2523music');+ expect(staticFile(unsafeName)).toBe('/test%252Fexample%2523music');+});++test('staticFile() should not encode slashes', () => {+ const nameWithSlashes = '/test/example/word';+ expect(staticFile(nameWithSlashes)).toBe(nameWithSlashes);+});++test('staticFile() should encode all problematic characters except slashes', () => {+ const nameWithSlashes = '/test/#example/$word';+ expect(staticFile(nameWithSlashes)).toBe('/test/%23example/%24word');});