Skip to content
Myr

Started moving helpers to their own file

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

authored by visionmedia · committed by visionmedia · parent 82e9327 · Browse files · 2 files+19 added−17 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+19 added−17 removed

  • other:+19 added−17 removed

2 files+19 added−17 removed

modified:lib/express/core.js+5 added-17 removed
12// Express - Core - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34process.mixin(require('sys'))5process.mixin(require('express/helpers'))67// --- ExpressError89ExpressError = Class({
28 unmodified lines
38 this.message = 'failed to find ' + request.method + ' ' + jsonEncode(request.uri.path)39 }40})4141var captures = [],42 params = {}4342Router = Class({43 params: {},44 captures: [],45 route: function(request){46 this.request = request47 return this.matchingRoute().run()48 },
14 unmodified lines
63 */6465 match: function(route) {66 if (this.request.method.toLowerCase() == route.method)67 if (captures = this.request.uri.path.match(route.path)) {67 if (this.captures = this.request.uri.path.match(route.path)) {68 this.mapParams()69 return true70 }71 },72 73 mapParams: function() {74 for (var i = 0, len = keys.length; i < len; ++i)75 params[keys[i]] = captures[i+1]75 this.params[keys[i]] = this.captures[i+1]76 }77})7879// --- Server
42 unmodified lines
122function normalizePath(path) {123 return path.replace(/[\s\/]*$/g, '')124}125126param = function(key) {127 return params[key]128}129130jsonEncode = function(object) {131 return JSON.stringify(object)132}133134dirname = function(path) {135 return path.split('/').slice(0, -1).join('/')136}137126/**127 * Escape special characters in _html_.128 *129 * @param {string} html
122 unmodified lines
added:lib/express/helpers.js+14 added