Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Last active June 1, 2016 23:15
Show Gist options
  • Save mattmazzola/23c4bc8c238b5f10aa3c804e476549cc to your computer and use it in GitHub Desktop.
Save mattmazzola/23c4bc8c238b5f10aa3c804e476549cc to your computer and use it in GitHub Desktop.
Route Recognizer Wildcard Test
let RouteRecognizer = require("route-recognizer");
let router = new RouteRecognizer();
router.add([{ path: '*path', handler: null }]);
router.add([{ path: '/report/pages', handler: null }]);
router.add([{ path: '/report/pages/:pageName', handler: null }]);
router.add([{ path: '/report/pages/:pageName/visuals/:visualId', handler: null }]);
let getPages = router.recognize('/report/pages');
console.log('/report/pages: ', getPages);
let matches = router.recognize('/report/pages/page1');
console.log('matches: ', matches);
let matches2 = router.recognize('/report/pages/page1/visuals/visual1');
console.log('matches2: ', matches2);
let matches3 = router.recognize('abc123');
console.log('matches3: ', matches3);
let matches4 = router.recognize('abc123/asdfasdf');
console.log('abc123/asdfasdf: ', matches4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment