🎥 Make videos programmatically with React
fix stills test
Jonny Burger4d2b5a7dbe14
diff --git a/packages/renderer/src/get-bundle-url-from-serve-url.ts b/packages/renderer/src/get-bundle-url-from-serve-url.tsindex 8559b70194..f17610ca49 100644--- a/packages/renderer/src/get-bundle-url-from-serve-url.ts+++ b/packages/renderer/src/get-bundle-url-from-serve-url.ts@@ -1,13 +1,27 @@import {Internals} from 'remotion';+import {isServeUrl} from './is-serve-url';+import path from 'path';-export const getBundleUrlFromServeUrl = (serveUrl: string) => {- const index = serveUrl.lastIndexOf('/');- const url = serveUrl.substring(0, index + 1) + Internals.bundleName;+const map = (webpackBundleOrServeUrl: string, suffix: string) => {+ if (isServeUrl(webpackBundleOrServeUrl)) {+ const parsed = new URL(webpackBundleOrServeUrl);+ const idx = parsed.pathname.lastIndexOf('/');+ if (idx === -1) {+ return parsed.origin + '/' + suffix;+ }++ return parsed.origin + parsed.pathname.substring(0, idx + 1) + suffix;+ }++ const index = webpackBundleOrServeUrl.lastIndexOf(path.sep);+ const url = webpackBundleOrServeUrl.substring(0, index + 1) + suffix;return url;};+export const getBundleUrlFromServeUrl = (serveUrl: string) => {+ return map(serveUrl, Internals.bundleName);+};+export const getBundleMapUrlFromServeUrl = (serveUrl: string) => {- const index = serveUrl.lastIndexOf('/');- const url = serveUrl.substring(0, index + 1) + Internals.bundleMapName;- return url;+ return map(serveUrl, Internals.bundleMapName);};diff --git a/packages/renderer/src/test/get-bundle-url-from-serve-url.test.ts b/packages/renderer/src/test/get-bundle-url-from-serve-url.test.tsindex 2e7bc4f9e4..fce38b1a33 100644--- a/packages/renderer/src/test/get-bundle-url-from-serve-url.test.ts+++ b/packages/renderer/src/test/get-bundle-url-from-serve-url.test.ts@@ -1,7 +1,11 @@import {expect, test} from 'vitest';-import {getBundleUrlFromServeUrl} from '../get-bundle-url-from-serve-url';+import {+ getBundleMapUrlFromServeUrl,+ getBundleUrlFromServeUrl,+} from '../get-bundle-url-from-serve-url';+import path from 'path';-test('get bundle url from serve url', async () => {+test('get bundle url from serve url', () => {const expected = getBundleUrlFromServeUrl('https://remotionlambda-gc1w0xbfzl.s3.eu-central-1.amazonaws.com/sites/testbed-v6/index.html');@@ -10,3 +14,46 @@ test('get bundle url from serve url', async () => {'https://remotionlambda-gc1w0xbfzl.s3.eu-central-1.amazonaws.com/sites/testbed-v6/bundle.js');});++test('get bundle url from localhost', () => {+ const expected = getBundleUrlFromServeUrl('http://localhost:3000');++ expect(expected).toBe('http://localhost:3000/bundle.js');+});++test('get bundle url from localhost with bundle.js', () => {+ const expected = getBundleMapUrlFromServeUrl(+ 'http://localhost:3000/bundle.js'+ );++ expect(expected).toBe('http://localhost:3000/bundle.js.map');+});++test('get bundle url from localhost with bundle.js', () => {+ const expected = getBundleMapUrlFromServeUrl('http://localhost:3000/');++ expect(expected).toBe('http://localhost:3000/bundle.js.map');+});++test('get bundle url from localhost with bundle.js', () => {+ const expected = getBundleMapUrlFromServeUrl(+ 'http://localhost:3000/hithere/index.html'+ );++ expect(expected).toBe('http://localhost:3000/hithere/bundle.js.map');+});++test('get bundle url from local path', () => {+ const expected = getBundleMapUrlFromServeUrl(+ `${path.sep}var${path.sep}bundle`+ );++ expect(expected).toBe('/var/bundle.js.map');+});+test('get bundle url from local path index.html', () => {+ const expected = getBundleMapUrlFromServeUrl(+ path.join('var', 'bundle', 'index.html')+ );++ expect(expected).toBe('var/bundle/bundle.js.map');+});