Skip to content
Myr

Added Express.arg()

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

authored by visionmedia · committed by visionmedia · parent b4896c4 · Browse files · 2 files+21 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+21 added−0 removed

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

2 files+21 added−0 removed

modified:lib/express.core.js+12 added
317 unmodified lines
318 if (node.http.STATUS_CODES.hasOwnProperty(code))319 if (node.http.STATUS_CODES[code].toLowerCase() == value.toLowerCase())320 return this.response.status = parseInt(code)321 },322323 /**324 * Return path segment _n_.325 *326 * @param {int} n327 * @return {string}328 * @api public329 */330 331 arg : function(n) {332 return this.request.uri.path.split('/')[n]333 },334 335 /**336 * Set response _status_ and _body_.337 *338 * @param {string} body
353 unmodified lines
modified:spec/spec.core.js+9 added
81 unmodified lines
82 Express.header('content-type').should.eql 'text/html'83 end84 end85 86 describe '.arg()'87 it 'should return the given path segment'88 Express.request = mockRequest({ uri : { path : 'some/foo-bar/baz' }})89 Express.arg(0).should.eql 'some'90 Express.arg(1).should.eql 'foo-bar'91 Express.arg(2).should.eql 'baz'92 end93 end94 95 describe '.status()'96 after_each97 Express.response.status = 20098 end
112 unmodified lines