aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/express/lib/router/route.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2012-11-06 20:59:25 -0800
committerAdam Soltys <[email protected]>2012-11-06 22:56:57 -0800
commit5f907fcf5b98c5be780bb0edfe830b96d068e585 (patch)
tree6819e040a4bc8f41330103dd9cb54ba528c550d1 /node_modules/express/lib/router/route.js
parent08f341f692688f077e9080bded2b14fdd5979c1e (diff)
downloadcoinos-server-5f907fcf5b98c5be780bb0edfe830b96d068e585.tar.gz
coinos-server-5f907fcf5b98c5be780bb0edfe830b96d068e585.zip
Use node and express
Diffstat (limited to 'node_modules/express/lib/router/route.js')
-rw-r--r--node_modules/express/lib/router/route.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/node_modules/express/lib/router/route.js b/node_modules/express/lib/router/route.js
new file mode 100644
index 00000000..c1a0b5ea
--- /dev/null
+++ b/node_modules/express/lib/router/route.js
@@ -0,0 +1,72 @@
+
+/**
+ * Module dependencies.
+ */
+
+var utils = require('../utils');
+
+/**
+ * Expose `Route`.
+ */
+
+module.exports = Route;
+
+/**
+ * Initialize `Route` with the given HTTP `method`, `path`,
+ * and an array of `callbacks` and `options`.
+ *
+ * Options:
+ *
+ * - `sensitive` enable case-sensitive routes
+ * - `strict` enable strict matching for trailing slashes
+ *
+ * @param {String} method
+ * @param {String} path
+ * @param {Array} callbacks
+ * @param {Object} options.
+ * @api private
+ */
+
+function Route(method, path, callbacks, options) {
+ options = options || {};
+ this.path = path;
+ this.method = method;
+ this.callbacks = callbacks;
+ this.regexp = utils.pathRegexp(path
+ , this.keys = []
+ , options.sensitive
+ , options.strict);
+}
+
+/**
+ * Check if this route matches `path`, if so
+ * populate `.params`.
+ *
+ * @param {String} path
+ * @return {Boolean}
+ * @api private
+ */
+
+Route.prototype.match = function(path){
+ var keys = this.keys
+ , params = this.params = []
+ , m = this.regexp.exec(path);
+
+ if (!m) return false;
+
+ for (var i = 1, len = m.length; i < len; ++i) {
+ var key = keys[i - 1];
+
+ var val = 'string' == typeof m[i]
+ ? decodeURIComponent(m[i])
+ : m[i];
+
+ if (key) {
+ params[key.name] = val;
+ } else {
+ params.push(val);
+ }
+ }
+
+ return true;
+};