« get me outta code hell

Output to file 'Foo Bar.mp3' instead of 'Foo%20Bar.mp3' - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLiam <towerofnix@gmail.com>2017-06-13 12:25:00 -0300
committerLiam <towerofnix@gmail.com>2017-06-13 12:25:00 -0300
commite3aab40a0ac45ae13384b28b27c242ff11a7c4d4 (patch)
tree5cf85eb6f7a9d21b4e11ac3a7c330ead9328aa9a /src
parenta056ebe64ecedcc73874b1d06ab19eb235780147 (diff)
Output to file 'Foo Bar.mp3' instead of 'Foo%20Bar.mp3'
Diffstat (limited to 'src')
-rw-r--r--src/downloaders.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/downloaders.js b/src/downloaders.js
index ad322fa..fa1f337 100644
--- a/src/downloaders.js
+++ b/src/downloaders.js
@@ -3,6 +3,7 @@ const fetch = require('node-fetch')
 const promisifyProcess = require('./promisify-process')
 const tempy = require('tempy')
 const path = require('path')
+const sanitize = require('sanitize-filename')
 
 const { spawn } = require('child_process')
 const { promisify } = require('util')
@@ -12,7 +13,7 @@ const writeFile = promisify(fs.writeFile)
 function makeHTTPDownloader() {
   return function(arg) {
     const dir = tempy.directory()
-    const out = dir + '/' + path.basename(arg)
+    const out = dir + '/' + sanitize(decodeURIComponent(path.basename(arg)))
 
     return fetch(arg)
       .then(response => response.buffer())