CartoDB-SQL-API/lib/utils/filename-sanitizer.js

10 lines
287 B
JavaScript
Raw Normal View History

'use strict';
var path = require('path');
2019-12-27 00:46:27 +08:00
module.exports = function sanitizeFilename (filename) {
2019-12-24 01:19:08 +08:00
filename = path.basename(filename, path.extname(filename));
2019-12-27 00:46:27 +08:00
filename = filename.replace(/[;()\[\]<>'"\s]/g, '_'); // eslint-disable-line no-useless-escape
2019-12-24 01:19:08 +08:00
return filename;
};