Skip to content

🎥 Make videos programmatically with React

fixed dot as file start

Patric Salvisberg34c61fec1646
diff --git a/packages/cli/src/editor/components/RenderModal/out-name-checker.ts b/packages/cli/src/editor/components/RenderModal/out-name-checker.ts
index b568b21764..29f71aa79c 100644
--- a/packages/cli/src/editor/components/RenderModal/out-name-checker.ts
+++ b/packages/cli/src/editor/components/RenderModal/out-name-checker.ts
@@ -38,6 +38,7 @@ export const validateOutnameGui = ({
});
return {valid: true};
} catch (err) {
+ console.log({valid: false, error: err as Error});
return {valid: false, error: err as Error};
}
};
@@ -66,6 +67,17 @@ const isValidOutName = ({
);
}
+ const hasDotAfterSlash = () => {
+ const substrings = prefix.split('/');
+ for (const str of substrings) {
+ if (str[0] === '.') {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
const hasInvalidChar = () => {
return prefix.split('').some((char) => invalidCharacters.includes(char));
};
@@ -83,7 +95,7 @@ const isValidOutName = ({
throw new Error('The prefix must be at least 1 character long');
}
- if (prefix[0] === '.') {
+ if (prefix[0] === '.' || hasDotAfterSlash()) {
throw new Error('The output name must not start with a dot');
}
diff --git a/packages/cli/src/test/validate-gui-output-filename.test.ts b/packages/cli/src/test/validate-gui-output-filename.test.ts
index ad307a513a..c90a56f164 100644
--- a/packages/cli/src/test/validate-gui-output-filename.test.ts
+++ b/packages/cli/src/test/validate-gui-output-filename.test.ts
@@ -1,14 +1,26 @@
import {expect, test} from 'vitest';
import {validateOutnameGui} from '../editor/components/RenderModal/out-name-checker';
-test('Should catch dot in front', () => {
- expect(() =>
+test('Should catch dot after slash', () => {
+ expect(
validateOutnameGui({
outName: 'out/.looped.mp4',
codec: 'h264',
audioCodec: 'aac',
renderMode: 'video',
stillImageFormat: 'png',
- })
- ).toThrow();
+ }).valid
+ ).toBe(false);
+});
+
+test('Should catch dot in front ', () => {
+ expect(
+ validateOutnameGui({
+ outName: '.looped.mp4',
+ codec: 'h264',
+ audioCodec: 'aac',
+ renderMode: 'video',
+ stillImageFormat: 'png',
+ }).valid
+ ).toBe(false);
});