Skip to content

Commit

Permalink
refactor sanitizePath a bit more.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington committed Jan 11, 2014
1 parent 2f12cf0 commit 07fe041
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 2 additions & 12 deletions lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,8 @@ util.isStream = function(source) {
};

util.sanitizePath = function() {
var filepath = util.unixifyPath.apply(util, arguments);
filepath = filepath.replace(':', '');

if (filepath === '.') {
filepath = '';
}

while (filepath.substring(0, 1) === '/') {
filepath = filepath.substring(1);
}

return filepath;
var filepath = path.join.apply(path, arguments);
return filepath.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
};

util.unixifyPath = function() {
Expand Down
6 changes: 4 additions & 2 deletions lib/zip-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ ZipStream.prototype._newProcessStream = function(store) {
ZipStream.prototype._normalizeFileData = function(data) {
data = util.defaults(data, {
type: 'file',
name: '',
name: null,
date: null,
store: false,
comment: ''
});

data.name = util.sanitizePath(data.name);
if (data.name) {
data.name = util.sanitizePath(data.name);
}

if (typeof data.lastModifiedDate !== 'number') {
data.lastModifiedDate = util.dosDateTime(data.date, this.options.forceUTC);
Expand Down

0 comments on commit 07fe041

Please sign in to comment.