Created
May 12, 2015 20:21
-
-
Save andineck/f863a38d699976830de9 to your computer and use it in GitHub Desktop.
path-to-regexp PR54 tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// patch: "path-to-regexp": "git://github.com/pillarjs/path-to-regexp.git#asterisk-match" | |
var patch = require('./patch/node_modules/path-to-regexp'); | |
// old: "path-to-regexp": "^0.1.3" | |
var old = require('./0.1.3/node_modules/path-to-regexp'); | |
var assert = require('assert'); | |
// routes: 0: route, 1: path, 2: param | |
var routes = [ | |
['*', '/test/route/aA/bB/cC', '/test/route/aA/bB/cC'], | |
['/*', '/test/route/aA/bB/cC', 'test/route/aA/bB/cC'], | |
['/test*', '/test/route/aA/bB/cC', '/route/aA/bB/cC'], | |
['/test/*', '/test/route/aA/bB/cC', 'route/aA/bB/cC'], | |
['/test/route/*', '/test/route/aA/bB/cC', 'aA/bB/cC'] | |
// -> fails with named parameters with wildcard on the old old: -> 'route' | |
//['/test/:path*', '/test/route/aA/bB/cC', 'route/aA/bB/cC'] | |
]; | |
var keys, result; | |
routes.forEach(function(route) { | |
keys = []; | |
result = patch(route[0], keys).exec(route[1]); | |
assert.equal(route[2], result[1]); | |
result = old(route[0], keys).exec(route[1]); | |
assert.equal(route[2], result[1]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment