From 862d1d02da322ab620d2b741b66f904859209c1f Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 15 Jul 2017 18:21:42 -0400 Subject: Update makeLocalDownloader to support 'file://' strings --- src/downloaders.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/downloaders.js b/src/downloaders.js index bc9cf15..c0e54eb 100644 --- a/src/downloaders.js +++ b/src/downloaders.js @@ -58,10 +58,17 @@ function makeLocalDownloader() { // platform way). return function(arg) { + // It's possible the downloader argument start with the "file://" protocol + // string; in that case we'll want to snip it off and URL-decode the + // string. + const fileProto = 'file://' + if (arg.startsWith(fileProto)) { + arg = decodeURIComponent(arg.slice(fileProto.length)) + } + const dir = tempy.directory() // TODO: Is it necessary to sanitize here? - // haha, the answer to "should I sanitize" is probably always - // YES.. + // Haha, the answer to "should I sanitize" is probably always YES.. const base = path.basename(arg, path.extname(arg)) const file = dir + '/' + sanitize(base) + '.mp3' return copyFile(arg, file) -- cgit 1.3.0-6-gf8a5