« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/downloaders.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/downloaders.js')
-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())