Skip to content

Commit 42506e6

Browse files
committed
Throw error when corePath is not a string
1 parent e9c705d commit 42506e6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/browser/getCreateFFmpegCore.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const resolveURL = require('resolve-url');
22
const { log } = require('../utils/log');
33

44
module.exports = async ({ corePath: _corePath }) => {
5+
if (typeof _corePath !== 'string') {
6+
throw Error('corePath should be a string!');
7+
}
58
if (typeof window.createFFmpegCore === 'undefined') {
69
log('info', 'fetch ffmpeg-core.worker.js script');
710
const corePath = resolveURL(_corePath);

tests/ffmpeg.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
const { createFFmpeg } = FFmpeg;
22

33
describe('load()', () => {
4+
it('should throw error when corePath is not a string', async () => {
5+
const ffmpeg = createFFmpeg({ ...OPTIONS, corePath: null });
6+
7+
try {
8+
await ffmpeg.load();
9+
} catch (e) {
10+
expect(e).to.be.an('Error');
11+
}
12+
});
413
it('should throw error when not called before FS() and run()', () => {
514
const ffmpeg = createFFmpeg(OPTIONS);
615
expect(() => ffmpeg.FS('readdir', 'dummy')).to.throw();

0 commit comments

Comments
 (0)