diff --git a/HISTORY.md b/HISTORY.md index 741989e..746e4a8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ unreleased - deps: setprototypeof@1.1.0 - deps: statuses@'>= 1.3.1 < 2' * deps: statuses@~1.5.0 + * perf: remove redundant `path.normalize` call 0.16.2 / 2018-02-07 =================== diff --git a/index.js b/index.js index f297c4c..9ee0e70 100644 --- a/index.js +++ b/index.js @@ -546,7 +546,6 @@ SendStream.prototype.pipe = function pipe (res) { // join / normalize from optional root dir path = normalize(join(root, path)) - root = normalize(root + sep) } else { // ".." is malicious without "root" if (UP_PATH_REGEXP.test(path)) { @@ -795,6 +794,15 @@ SendStream.prototype.stream = function stream (path, options) { // pipe var stream = fs.createReadStream(path, options) + + // apply additional transformation streams if any + if (options.transformStreams) { + for(var i = 0; i < options.transformStreams.length; i++) { + var transform = options.transformStreams[i]; + stream = stream.pipe(transform); + } + } + this.emit('stream', stream) stream.pipe(res)