Skip to content
Myr

Use path-is-absolute module for absolute path detection

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #2620

authored by Jeremiah Senkpiel · committed by Douglas Christopher Wilson · parent cec5780 · Browse files · 5 files+4 added−32 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+4 added−32 removed

  • tests:+0 added−16 removed
  • other:+4 added−16 removed

5 files+4 added−32 removed

modified:lib/response.js+2 added-2 removed
14 unmodified lines
15var contentDisposition = require('content-disposition');16var deprecate = require('depd')('express');17var escapeHtml = require('escape-html');18var http = require('http');19var isAbsolute = require('./utils').isAbsolute;19var onFinished = require('on-finished');20var path = require('path');21var pathIsAbsolute = require('path-is-absolute');22var merge = require('utils-merge');23var sign = require('cookie-signature').sign;24var normalizeType = require('./utils').normalizeType;25var normalizeTypes = require('./utils').normalizeTypes;
342 unmodified lines
368 done = options;369 opts = {};370 }371372 if (!opts.root && !isAbsolute(path)) {372 if (!opts.root && !pathIsAbsolute(path)) {373 throw new TypeError('path must be absolute or specify root to res.sendFile');374 }375376 // create file stream
575 unmodified lines
modified:lib/utils.js-14 removed
53 unmodified lines
54 return etag(buf, {weak: true});55};5657/**58 * Check if `path` looks absolute.59 *60 * @param {String} path61 * @return {Boolean}62 * @api private63 */6465exports.isAbsolute = function(path){66 if ('/' == path[0]) return true;67 if (':' == path[1] && '\\' == path[2]) return true;68 if ('\\\\' == path.substring(0, 2)) return true; // Microsoft Azure absolute path69};7071/**58 * Normalize the given `type`, for example "html" becomes "text/html".59 *60 * @param {String} type61 * @return {Object}
187 unmodified lines
modified:test/utils.js-16 removed
modified:History.md+1 added
7 unmodified lines
8 - `req.param()` -- use `req.params`, `req.body`, or `req.query` instead9 * change:10 - The leading `:` character in `name` for `app.param(name, fn)` is no longer removed11 - Use `router` module for routing12 - Use `path-is-absolute` module for absolute path detection13145.0.0-alpha.1 / 2014-11-0615==========================16
3010 unmodified lines
modified:package.json+1 added