diff options
author | Liam <towerofnix@gmail.com> | 2017-07-15 18:21:42 -0400 |
---|---|---|
committer | Liam <towerofnix@gmail.com> | 2017-07-15 18:21:42 -0400 |
commit | 862d1d02da322ab620d2b741b66f904859209c1f (patch) | |
tree | d62ebea901676f7d9c7cd9062cfb479af2d6f5d1 /src | |
parent | 6b6840973c120896c2d4f40bd29b1ac86f5973f6 (diff) |
Update makeLocalDownloader to support 'file://' strings
Diffstat (limited to 'src')
-rw-r--r-- | src/downloaders.js | 11 |
1 files 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) |