Skip to content
Myr

Added shorthand for the parsed request's pathname

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e9abe1b · Browse files · 2 files+24 added−0 removed
This commit

State

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

Diff stats

2 files+24 added−0 removed

  • tests:+12 added−0 removed
  • other:+12 added−0 removed

2 files+24 added−0 removed

modified:lib/request.js+12 added
10 unmodified lines
1112var http = require('http')13 , req = http.IncomingMessage.prototype14 , utils = require('./utils')15 , parse = require('url').parse16 , mime = require('mime');1718/**19 * Default notification formatters.
72 unmodified lines
92 return RegExp.$1 || RegExp.$2;93};9495/**96 * Short-hand for `require('url').parse(req.url).pathname`.97 *98 * @return {String}99 * @api public100 */101102req.__defineGetter__('path', function(){103 return parse(this.url).pathname;104});105106/**107 * Check if the _Accept_ header is present, and includes the given `type`.108 *109 * When the _Accept_ header is not present `true` is returned. Otherwise110 * the given `type` is matched by an exact match, and then subtypes. You
233 unmodified lines
modified:test/request.test.js+12 added
7 unmodified lines
8 , assert = require('assert')9 , should = require('should');1011module.exports = {12 'test #path': function(){13 var app = express.createServer();1415 app.get('/search', function(req, res){16 res.send(req.path);17 });1819 assert.response(app,20 { url: '/search?q=tobi' },21 { body: '/search' });22 },2324 'test #isXMLHttpRequest': function(){25 var app = express.createServer();2627 app.get('/isxhr', function(req, res){
326 unmodified lines