Skip to content

Commit

Permalink
Allow spaces in file names
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcclure22 committed Apr 9, 2018
1 parent 06d4096 commit a277633
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ exports.getFileName = function(key, options) {
// reserved characters in Windows filenames.
// See: https://en.wikipedia.org/wiki/Filename#Reserved%5Fcharacters%5Fand%5Fwords
const escapedFileName = encodeURIComponent(keyFileName)
.replace(/\*/g, '-');
.replace(/\*/g, '-').replace(/%20/g, ' ');

return path.join(options.dataPath || exports.getDataPath(), escapedFileName);
};
5 changes: 5 additions & 0 deletions tests/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ describe('Utils', function() {
m.chai.expect(path.basename(fileName)).to.equal('john6638%40gmail-dot-com.json');
});

it('should allow spaces in file names', function() {
const fileName = utils.getFileName('foo bar');
m.chai.expect(path.basename(fileName)).to.equal('foo bar.json');
});

it('should react to user data path changes', function() {
const newUserDataPath = path.join(utils.getDataPath(), 'foo' , 'bar');
utils.setDataPath(newUserDataPath);
Expand Down

0 comments on commit a277633

Please sign in to comment.