aboutsummaryrefslogtreecommitdiffstats
path: root/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp
diff options
context:
space:
mode:
Diffstat (limited to 'dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp')
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/.npmignore2
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/History.md16
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/Readme.md33
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/component.json15
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/index.js70
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/package.json161
-rw-r--r--dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/test.js616
7 files changed, 913 insertions, 0 deletions
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/.npmignore b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/.npmignore
new file mode 100644
index 00000000..ba2a97b5
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+coverage
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/History.md b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/History.md
new file mode 100644
index 00000000..f962cfad
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/History.md
@@ -0,0 +1,16 @@
+0.1.3 / 2014-07-06
+==================
+
+ * Better array support
+ * Improved support for trailing slash in non-ending mode
+
+0.1.0 / 2014-03-06
+==================
+
+ * add options.end
+
+0.0.2 / 2013-02-10
+==================
+
+ * Update to match current express
+ * add .license property to component.json
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/Readme.md b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/Readme.md
new file mode 100644
index 00000000..9199e387
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/Readme.md
@@ -0,0 +1,33 @@
+
+# Path-to-RegExp
+
+ Turn an Express-style path string such as `/user/:name` into a regular expression.
+
+## Usage
+
+```javascript
+var pathToRegexp = require('path-to-regexp');
+```
+### pathToRegexp(path, keys, options)
+
+ - **path** A string in the express format, an array of such strings, or a regular expression
+ - **keys** An array to be populated with the keys present in the url. Once the function completes, this will be an array of strings.
+ - **options**
+ - **options.sensitive** Defaults to false, set this to true to make routes case sensitive
+ - **options.strict** Defaults to false, set this to true to make the trailing slash matter.
+ - **options.end** Defaults to true, set this to false to only match the prefix of the URL.
+
+```javascript
+var keys = [];
+var exp = pathToRegexp('/foo/:bar', keys);
+//keys = ['bar']
+//exp = /^\/foo\/(?:([^\/]+?))\/?$/i
+```
+
+## Live Demo
+
+You can see a live demo of this library in use at [express-route-tester](http://forbeslindesay.github.com/express-route-tester/).
+
+## License
+
+ MIT \ No newline at end of file
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/component.json b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/component.json
new file mode 100644
index 00000000..6ab37d36
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/component.json
@@ -0,0 +1,15 @@
+{
+ "name": "path-to-regexp",
+ "description": "Express style path to RegExp utility",
+ "version": "0.1.3",
+ "keywords": [
+ "express",
+ "regexp",
+ "route",
+ "routing"
+ ],
+ "scripts": [
+ "index.js"
+ ],
+ "license": "MIT"
+}
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/index.js b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/index.js
new file mode 100644
index 00000000..2801f914
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/index.js
@@ -0,0 +1,70 @@
+/**
+ * Expose `pathtoRegexp`.
+ */
+
+module.exports = pathtoRegexp;
+
+/**
+ * Normalize the given path string,
+ * returning a regular expression.
+ *
+ * An empty array should be passed,
+ * which will contain the placeholder
+ * key names. For example "/user/:id" will
+ * then contain ["id"].
+ *
+ * @param {String|RegExp|Array} path
+ * @param {Array} keys
+ * @param {Object} options
+ * @return {RegExp}
+ * @api private
+ */
+
+function pathtoRegexp(path, keys, options) {
+ options = options || {};
+ var strict = options.strict;
+ var end = options.end !== false;
+ var flags = options.sensitive ? '' : 'i';
+ keys = keys || [];
+
+ if (path instanceof RegExp) {
+ return path;
+ }
+
+ if (Array.isArray(path)) {
+ // Map array parts into regexps and return their source. We also pass
+ // the same keys and options instance into every generation to get
+ // consistent matching groups before we join the sources together.
+ path = path.map(function (value) {
+ return pathtoRegexp(value, keys, options).source;
+ });
+
+ return new RegExp('(?:' + path.join('|') + ')', flags);
+ }
+
+ path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?'))
+ .replace(/\/\(/g, '/(?:')
+ .replace(/([\/\.])/g, '\\$1')
+ .replace(/(\\\/)?(\\\.)?:(\w+)(\(.*?\))?(\*)?(\?)?/g, function (match, slash, format, key, capture, star, optional) {
+ slash = slash || '';
+ format = format || '';
+ capture = capture || '([^\\/' + format + ']+?)';
+ optional = optional || '';
+
+ keys.push({ name: key, optional: !!optional });
+
+ return ''
+ + (optional ? '' : slash)
+ + '(?:'
+ + format + (optional ? slash : '') + capture
+ + (star ? '((?:[\\/' + format + '].+?)?)' : '')
+ + ')'
+ + optional;
+ })
+ .replace(/\*/g, '(.*)');
+
+ // If the path is non-ending, match until the end or a slash.
+ path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\/|$)'));
+
+ return new RegExp(path, flags);
+};
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/package.json b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/package.json
new file mode 100644
index 00000000..e682677b
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/package.json
@@ -0,0 +1,161 @@
+{
+ "name": "path-to-regexp",
+ "description": "Express style path to RegExp utility",
+ "version": "0.1.3",
+ "scripts": {
+ "test": "istanbul cover _mocha -- -R spec"
+ },
+ "keywords": [
+ "express",
+ "regexp"
+ ],
+ "component": {
+ "scripts": {
+ "path-to-regexp": "index.js"
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/component/path-to-regexp.git"
+ },
+ "devDependencies": {
+ "mocha": "^1.17.1",
+ "istanbul": "^0.2.6"
+ },
+ "bugs": {
+ "url": "https://github.com/component/path-to-regexp/issues"
+ },
+ "homepage": "https://github.com/component/path-to-regexp",
+ "_id": "path-to-regexp@0.1.3",
+ "_shasum": "21b9ab82274279de25b156ea08fd12ca51b8aecb",
+ "_from": "path-to-regexp@0.1.3",
+ "_npmVersion": "1.4.9",
+ "_npmUser": {
+ "name": "blakeembrey",
+ "email": "hello@blakeembrey.com"
+ },
+ "maintainers": [
+ {
+ "name": "tjholowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ {
+ "name": "jongleberry",
+ "email": "jonathanrichardong@gmail.com"
+ },
+ {
+ "name": "dominicbarnes",
+ "email": "dominic@dbarnes.info"
+ },
+ {
+ "name": "tootallnate",
+ "email": "nathan@tootallnate.net"
+ },
+ {
+ "name": "rauchg",
+ "email": "rauchg@gmail.com"
+ },
+ {
+ "name": "retrofox",
+ "email": "rdsuarez@gmail.com"
+ },
+ {
+ "name": "coreh",
+ "email": "thecoreh@gmail.com"
+ },
+ {
+ "name": "forbeslindesay",
+ "email": "forbes@lindesay.co.uk"
+ },
+ {
+ "name": "kelonye",
+ "email": "kelonyemitchel@gmail.com"
+ },
+ {
+ "name": "mattmueller",
+ "email": "mattmuelle@gmail.com"
+ },
+ {
+ "name": "yields",
+ "email": "yields@icloud.com"
+ },
+ {
+ "name": "anthonyshort",
+ "email": "antshort@gmail.com"
+ },
+ {
+ "name": "ianstormtaylor",
+ "email": "ian@ianstormtaylor.com"
+ },
+ {
+ "name": "cristiandouce",
+ "email": "cristian@gravityonmars.com"
+ },
+ {
+ "name": "swatinem",
+ "email": "arpad.borsos@googlemail.com"
+ },
+ {
+ "name": "stagas",
+ "email": "gstagas@gmail.com"
+ },
+ {
+ "name": "amasad",
+ "email": "amjad.masad@gmail.com"
+ },
+ {
+ "name": "juliangruber",
+ "email": "julian@juliangruber.com"
+ },
+ {
+ "name": "shtylman",
+ "email": "shtylman@gmail.com"
+ },
+ {
+ "name": "calvinfo",
+ "email": "calvin@calv.info"
+ },
+ {
+ "name": "blakeembrey",
+ "email": "hello@blakeembrey.com"
+ },
+ {
+ "name": "timoxley",
+ "email": "secoif@gmail.com"
+ },
+ {
+ "name": "jonathanong",
+ "email": "jonathanrichardong@gmail.com"
+ },
+ {
+ "name": "queckezz",
+ "email": "fabian.eichenberger@gmail.com"
+ },
+ {
+ "name": "nami-doc",
+ "email": "vendethiel@hotmail.fr"
+ },
+ {
+ "name": "clintwood",
+ "email": "clint@anotherway.co.za"
+ },
+ {
+ "name": "thehydroimpulse",
+ "email": "dnfagnan@gmail.com"
+ },
+ {
+ "name": "stephenmathieson",
+ "email": "me@stephenmathieson.com"
+ },
+ {
+ "name": "trevorgerhardt",
+ "email": "trevorgerhardt@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "21b9ab82274279de25b156ea08fd12ca51b8aecb",
+ "tarball": "http://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.3.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.3.tgz"
+}
diff --git a/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/test.js b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/test.js
new file mode 100644
index 00000000..4a0c2709
--- /dev/null
+++ b/dgbuilder/dgeflows/node_modules/express/node_modules/path-to-regexp/test.js
@@ -0,0 +1,616 @@
+var pathToRegExp = require('./');
+var assert = require('assert');
+
+describe('path-to-regexp', function () {
+ describe('strings', function () {
+ it('should match simple paths', function () {
+ var params = [];
+ var m = pathToRegExp('/test', params).exec('/test');
+
+ assert.equal(params.length, 0);
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/test');
+ });
+
+ it('should match express format params', function () {
+ var params = [];
+ var m = pathToRegExp('/:test', params).exec('/pathname');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/pathname');
+ assert.equal(m[1], 'pathname');
+ });
+
+ it('should do strict matches', function () {
+ var params = [];
+ var re = pathToRegExp('/:test', params, { strict: true });
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route');
+ assert.equal(m[1], 'route');
+
+ m = re.exec('/route/');
+
+ assert.ok(!m);
+ });
+
+ it('should do strict matches with trailing slashes', function () {
+ var params = [];
+ var re = pathToRegExp('/:test/', params, { strict: true });
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/route');
+
+ assert.ok(!m);
+
+ m = re.exec('/route/');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route/');
+ assert.equal(m[1], 'route');
+
+ m = re.exec('/route//');
+
+ assert.ok(!m);
+ });
+
+ it('should allow optional express format params', function () {
+ var params = [];
+ var re = pathToRegExp('/:test?', params);
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, true);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route');
+ assert.equal(m[1], 'route');
+
+ m = re.exec('/');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/');
+ assert.equal(m[1], undefined);
+ });
+
+ it('should allow express format param regexps', function () {
+ var params = [];
+ var m = pathToRegExp('/:page(\\d+)', params).exec('/56');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'page');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/56');
+ assert.equal(m[1], '56');
+ });
+
+ it('should match without a prefixed slash', function () {
+ var params = [];
+ var m = pathToRegExp(':test', params).exec('string');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], 'string');
+ assert.equal(m[1], 'string');
+ });
+
+ it('should not match format parts', function () {
+ var params = [];
+ var m = pathToRegExp('/:test.json', params).exec('/route.json');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route.json');
+ assert.equal(m[1], 'route');
+ });
+
+ it('should match format parts', function () {
+ var params = [];
+ var re = pathToRegExp('/:test.:format', params);
+ var m;
+
+ assert.equal(params.length, 2);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+ assert.equal(params[1].name, 'format');
+ assert.equal(params[1].optional, false);
+
+ m = re.exec('/route.json');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/route.json');
+ assert.equal(m[1], 'route');
+ assert.equal(m[2], 'json');
+
+ m = re.exec('/route');
+
+ assert.ok(!m);
+ });
+
+ it('should match route parts with a trailing format', function () {
+ var params = [];
+ var m = pathToRegExp('/:test.json', params).exec('/route.json');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route.json');
+ assert.equal(m[1], 'route');
+ });
+
+ it('should match optional trailing routes', function () {
+ var params = [];
+ var m = pathToRegExp('/test*', params).exec('/test/route');
+
+ assert.equal(params.length, 0);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test/route');
+ assert.equal(m[1], '/route');
+ });
+
+ it('should match optional trailing routes after a param', function () {
+ var params = [];
+ var re = pathToRegExp('/:test*', params);
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/test/route');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/test/route');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '/route');
+
+ m = re.exec('/testing');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/testing');
+ assert.equal(m[1], 'testing');
+ assert.equal(m[2], '');
+ });
+
+ it('should match optional trailing routes before a format', function () {
+ var params = [];
+ var re = pathToRegExp('/test*.json', params);
+ var m;
+
+ assert.equal(params.length, 0);
+
+ m = re.exec('/test.json');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test.json');
+ assert.equal(m[1], '');
+
+ m = re.exec('/testing.json');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/testing.json');
+ assert.equal(m[1], 'ing');
+
+ m = re.exec('/test/route.json');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test/route.json');
+ assert.equal(m[1], '/route');
+ });
+
+ it('should match optional trailing routes after a param and before a format', function () {
+ var params = [];
+ var re = pathToRegExp('/:test*.json', params);
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/testing.json');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/testing.json');
+ assert.equal(m[1], 'testing');
+ assert.equal(m[2], '');
+
+ m = re.exec('/test/route.json');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/test/route.json');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '/route');
+
+ m = re.exec('.json');
+
+ assert.ok(!m);
+ });
+
+ it('should match optional trailing routes between a normal param and a format param', function () {
+ var params = [];
+ var re = pathToRegExp('/:test*.:format', params);
+ var m;
+
+ assert.equal(params.length, 2);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+ assert.equal(params[1].name, 'format');
+ assert.equal(params[1].optional, false);
+
+ m = re.exec('/testing.json');
+
+ assert.equal(m.length, 4);
+ assert.equal(m[0], '/testing.json');
+ assert.equal(m[1], 'testing');
+ assert.equal(m[2], '');
+ assert.equal(m[3], 'json');
+
+ m = re.exec('/test/route.json');
+
+ assert.equal(m.length, 4);
+ assert.equal(m[0], '/test/route.json');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '/route');
+ assert.equal(m[3], 'json');
+
+ m = re.exec('/test');
+
+ assert.ok(!m);
+
+ m = re.exec('.json');
+
+ assert.ok(!m);
+ });
+
+ it('should match optional trailing routes after a param and before an optional format param', function () {
+ var params = [];
+ var re = pathToRegExp('/:test*.:format?', params);
+ var m;
+
+ assert.equal(params.length, 2);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+ assert.equal(params[1].name, 'format');
+ assert.equal(params[1].optional, true);
+
+ m = re.exec('/testing.json');
+
+ assert.equal(m.length, 4);
+ assert.equal(m[0], '/testing.json');
+ assert.equal(m[1], 'testing');
+ assert.equal(m[2], '');
+ assert.equal(m[3], 'json');
+
+ m = re.exec('/test/route.json');
+
+ assert.equal(m.length, 4);
+ assert.equal(m[0], '/test/route.json');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '/route');
+ assert.equal(m[3], 'json');
+
+ m = re.exec('/test');
+
+ assert.equal(m.length, 4);
+ assert.equal(m[0], '/test');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '');
+ assert.equal(m[3], undefined);
+
+ m = re.exec('.json');
+
+ assert.ok(!m);
+ });
+
+ it('should match optional trailing routes inside optional express param', function () {
+ var params = [];
+ var re = pathToRegExp('/:test*?', params);
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, true);
+
+ m = re.exec('/test/route');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/test/route');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '/route');
+
+ m = re.exec('/test');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/test');
+ assert.equal(m[1], 'test');
+ assert.equal(m[2], '');
+
+ m = re.exec('/');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/');
+ assert.equal(m[1], undefined);
+ assert.equal(m[2], undefined);
+ });
+
+ it('should do case insensitive matches', function () {
+ var m = pathToRegExp('/test').exec('/TEST');
+
+ assert.equal(m[0], '/TEST');
+ });
+
+ it('should do case sensitive matches', function () {
+ var re = pathToRegExp('/test', null, { sensitive: true });
+ var m;
+
+ m = re.exec('/test');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/test');
+
+ m = re.exec('/TEST');
+
+ assert.ok(!m);
+ });
+
+ it('should do non-ending matches', function () {
+ var params = [];
+ var m = pathToRegExp('/:test', params, { end: false }).exec('/test/route');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test');
+ assert.equal(m[1], 'test');
+ });
+
+ it('should match trailing slashes in non-ending non-strict mode', function () {
+ var params = [];
+ var re = pathToRegExp('/:test', params, { end: false });
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/test/');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test/');
+ assert.equal(m[1], 'test');
+ });
+
+ it('should match trailing slashes in non-ending non-strict mode', function () {
+ var params = [];
+ var re = pathToRegExp('/route/', params, { end: false });
+ var m;
+
+ assert.equal(params.length, 0);
+
+ m = re.exec('/route/');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route/');
+
+ m = re.exec('/route/test');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route');
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route');
+
+ m = re.exec('/route//');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route/');
+ });
+
+ it('should match trailing slashing in non-ending strict mode', function () {
+ var params = [];
+ var re = pathToRegExp('/route/', params, { end: false, strict: true });
+
+ assert.equal(params.length, 0);
+
+ m = re.exec('/route/');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route/');
+
+ m = re.exec('/route/test');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route/');
+
+ m = re.exec('/route');
+
+ assert.ok(!m);
+
+ m = re.exec('/route//');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route/');
+ });
+
+ it('should not match trailing slashes in non-ending strict mode', function () {
+ var params = [];
+ var re = pathToRegExp('/route', params, { end: false, strict: true });
+
+ assert.equal(params.length, 0);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 1);
+ assert.equal(m[0], '/route');
+
+ m = re.exec('/route/');
+
+ assert.ok(m.length, 1);
+ assert.equal(m[0], '/route');
+ });
+
+ it('should match text after an express param', function () {
+ var params = [];
+ var re = pathToRegExp('/(:test)route', params);
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ m = re.exec('/route');
+
+ assert.ok(!m);
+
+ m = re.exec('/testroute');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/testroute');
+ assert.equal(m[1], 'test');
+
+ m = re.exec('testroute');
+
+ assert.ok(!m);
+ });
+
+ it('should match text after an optional express param', function () {
+ var params = [];
+ var re = pathToRegExp('/(:test?)route', params);
+ var m;
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, true);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/route');
+ assert.equal(m[1], undefined);
+
+ m = re.exec('/testroute');
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/testroute');
+ assert.equal(m[1], 'test');
+
+ m = re.exec('route');
+
+ assert.ok(!m);
+ });
+
+ it('should match optional formats', function () {
+ var params = [];
+ var re = pathToRegExp('/:test.:format?', params);
+ var m;
+
+ assert.equal(params.length, 2);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+ assert.equal(params[1].name, 'format');
+ assert.equal(params[1].optional, true);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/route');
+ assert.equal(m[1], 'route');
+ assert.equal(m[2], undefined);
+
+ m = re.exec('/route.json');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/route.json');
+ assert.equal(m[1], 'route');
+ assert.equal(m[2], 'json');
+ });
+
+ it('should match full paths with format by default', function () {
+ var params = [];
+ var m = pathToRegExp('/:test', params).exec('/test.json');
+
+ assert.equal(params.length, 1);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+
+ assert.equal(m.length, 2);
+ assert.equal(m[0], '/test.json');
+ assert.equal(m[1], 'test.json');
+ });
+ });
+
+ describe('regexps', function () {
+ it('should return the regexp', function () {
+ assert.deepEqual(pathToRegExp(/.*/), /.*/);
+ });
+ });
+
+ describe('arrays', function () {
+ it('should join arrays parts', function () {
+ var re = pathToRegExp(['/test', '/route']);
+
+ assert.ok(re.test('/test'));
+ assert.ok(re.test('/route'));
+ assert.ok(!re.test('/else'));
+ });
+
+ it('should match parts properly', function () {
+ var params = [];
+ var re = pathToRegExp(['/:test', '/test/:route'], params);
+ var m;
+
+ assert.equal(params.length, 2);
+ assert.equal(params[0].name, 'test');
+ assert.equal(params[0].optional, false);
+ assert.equal(params[1].name, 'route');
+ assert.equal(params[1].optional, false);
+
+ m = re.exec('/route');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/route');
+ assert.equal(m[1], 'route');
+ assert.equal(m[2], undefined);
+
+ m = re.exec('/test/path');
+
+ assert.equal(m.length, 3);
+ assert.equal(m[0], '/test/path');
+ assert.equal(m[1], undefined);
+ assert.equal(m[2], 'path');
+ });
+ });
+});