🎥 Make videos programmatically with React
fix
Jonny Burger3022303e1153
diff --git a/packages/paths/src/reverse-path.ts b/packages/paths/src/reverse-path.tsindex 82a8f3da72..527317ac3c 100644--- a/packages/paths/src/reverse-path.ts+++ b/packages/paths/src/reverse-path.ts@@ -5,7 +5,11 @@* not recognise the public domain, where this code is MIT licensed.*/-import {normalizePath} from './normalize-path';+import {getSubpaths} from './get-subpaths';+import {normalizeInstructions} from './normalize-path';+import {parsePath} from './parse-path';+import {reduceInstructions} from './reduce-instructions';+import {serializeInstructions} from './serialize-instructions';/*** Normalise an SVG path to absolute coordinates@@ -142,11 +146,14 @@ function reverseNormalizedPath(normalized: string) {* @see [Documentation](https://remotion.dev/docs/paths/reverse-path)*/export const reversePath = (path: string) => {- const normalizedPath = normalizePath(path);- const paths = normalizedPath.replace(/M/g, '|M').split('|');- paths.splice(0, 1);+ const parsed = parsePath(path);+ const normalized = normalizeInstructions(parsed);+ const reduced = reduceInstructions(normalized);+ const serialized = serializeInstructions(reduced);- return paths+ const subPaths = getSubpaths(serialized);++ return subPaths.map((spath) => {return reverseNormalizedPath(spath.trim());})diff --git a/packages/paths/src/test/reverse-path.test.ts b/packages/paths/src/test/reverse-path.test.tsindex 876267badb..5d01d3e330 100644--- a/packages/paths/src/test/reverse-path.test.ts+++ b/packages/paths/src/test/reverse-path.test.ts@@ -7,3 +7,13 @@ test('Should be able to reverse a path', () => {`);expect(reversedPath).toEqual('M 100 0 L 0 0');});++test('Should not crash out', () => {+ expect(+ reversePath(+ 'M949 508V406.455C949 379.142 971.142 357 998.455 357V357C1025.77 357 1047.91 379.142 1047.91 406.455V508'+ )+ ).toEqual(+ 'M 1047.91 508 L 1047.91 406.455 C 1047.91 379.142 1025.77 357 998.455 357 L 998.455 357 C 971.142 357 949 379.142 949 406.455 L 949 508'+ );+});