From c51cb50b7afc97009629679bf4bfd5ff2c441b9e Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Fri, 20 Nov 2020 12:55:22 +0800 Subject: [PATCH] Throw error when corePath is not a string --- src/browser/getCreateFFmpegCore.js | 3 +++ tests/ffmpeg.test.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/browser/getCreateFFmpegCore.js b/src/browser/getCreateFFmpegCore.js index 725b1fe..f94985f 100644 --- a/src/browser/getCreateFFmpegCore.js +++ b/src/browser/getCreateFFmpegCore.js @@ -2,6 +2,9 @@ const resolveURL = require('resolve-url'); const { log } = require('../utils/log'); module.exports = async ({ corePath: _corePath }) => { + if (typeof _corePath !== 'string') { + throw Error('corePath should be a string!'); + } if (typeof window.createFFmpegCore === 'undefined') { log('info', 'fetch ffmpeg-core.worker.js script'); const corePath = resolveURL(_corePath); diff --git a/tests/ffmpeg.test.js b/tests/ffmpeg.test.js index f6c42e7..2a434cd 100644 --- a/tests/ffmpeg.test.js +++ b/tests/ffmpeg.test.js @@ -1,6 +1,15 @@ const { createFFmpeg } = FFmpeg; describe('load()', () => { + it('should throw error when corePath is not a string', async () => { + const ffmpeg = createFFmpeg({ ...OPTIONS, corePath: null }); + + try { + await ffmpeg.load(); + } catch (e) { + expect(e).to.be.an('Error'); + } + }); it('should throw error when not called before FS() and run()', () => { const ffmpeg = createFFmpeg(OPTIONS); expect(() => ffmpeg.FS('readdir', 'dummy')).to.throw();