From e6ef11622de56d5dc9167620a81a16aebbaa4fe6 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Tue, 25 Apr 2017 17:36:56 -0500 Subject: [PATCH] Sanitize file name --- package.json | 1 + src/helpers/util.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f53716a..7ac8e1a 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "react-dnd-html5-backend": "^2.1.2", "react-dom": "^15.4.2", "react-sortable-hoc": "^0.6.2", + "sanitize-filename": "^1.6.1", "string": "^3.3.3" }, "name": "alchemy", diff --git a/src/helpers/util.js b/src/helpers/util.js index d866435..fb780c5 100644 --- a/src/helpers/util.js +++ b/src/helpers/util.js @@ -1,9 +1,11 @@ +const sanitizeFileName = require('sanitize-filename') const { pluck, compose, map } = require('./functional') const { fileTypes } = require('./constants') const replaceSpaceCharacters = str => - str.replace(/\s/g, '\\ ') - .replace(/'/g, '\\\'') + sanitizeFileName(str) + .replace(/\s/g, '\\ ') + .replace(/'/g, '\\\'') const concatFiles = files => files.map(path => path.split('/').pop())