{"_id":"feather-route-matcher","_rev":"9-5796c1e5bd5dd33e3bec76cd357c6e30","name":"feather-route-matcher","description":"featherweight url to handler matching","dist-tags":{"latest":"4.0.0"},"versions":{"1.0.0":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"1.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"standard":"^5.4.1","tap-spec":"^4.1.1","tape":"^4.2.2"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"test":"node test.js | tap-spec && standard"},"gitHead":"a3f5e43a98d2f3faf87182d9150a94229b3ceb9b","_id":"feather-route-matcher@1.0.0","_shasum":"88f91e5d2093bcee0697eda38ee79a54a1872f44","_from":".","_npmVersion":"3.3.10","_nodeVersion":"4.1.0","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"shasum":"88f91e5d2093bcee0697eda38ee79a54a1872f44","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-1.0.0.tgz","integrity":"sha512-rW3pLngYLPFYZeZuQlx0WZTSn97lF5QPnbEW3YKAdwXgEeQVO1wcll7enpcitdUZ1cNKAoEYqwddY50RKHhKdg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCwV0BoJpcW2/eNwE/uADwExKUetYqDoOd30OnYan5BQIhAOs+FuxEpepF6BBRzAqwPQfGtgBUO2cc8lv7XaWP7btM"}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"directories":{}},"2.0.0":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"2.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"standard":"^5.4.1","tap-spec":"^4.1.1","tape":"^4.2.2"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"test":"node test.js | tap-spec && standard"},"gitHead":"0dad4c08b5d5f56097d00e94126acbd6a76056a7","_id":"feather-route-matcher@2.0.0","_shasum":"26f758240a89d72ec2f9abc32268eafac0e99752","_from":".","_npmVersion":"3.3.10","_nodeVersion":"4.1.0","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"shasum":"26f758240a89d72ec2f9abc32268eafac0e99752","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-2.0.0.tgz","integrity":"sha512-+Md4T9ShAmSQbUMwwCxKMby5eu7x+k2E/C4V7AYfnFIrmP/H69cOac6611gsxyu7Uxl9AXg/RZjqFe69qGRJ/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA21U5g4pO5Ji70oemiyyEvpYKCJuWXkRHWSdGZlJQKRAiBjKl7FbciD2rCf9f3uz5cJ/OOx8jxe/y9SKmapMMJN1w=="}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"_npmOperationalInternal":{"host":"packages-5-east.internal.npmjs.com","tmp":"tmp/feather-route-matcher-2.0.0.tgz_1455345743107_0.2815054962411523"},"directories":{}},"2.0.1":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"2.0.1","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"standard":"^5.4.1","tap-spec":"^4.1.1","tape":"^4.2.2"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"test":"node test.js | tap-spec && standard"},"gitHead":"23bed0d383247c854ee1432a0c60e49651c2d3e4","_id":"feather-route-matcher@2.0.1","_shasum":"063a65094622b4451ecf9814734c2b6ca85c33c4","_from":".","_npmVersion":"3.7.2","_nodeVersion":"4.1.0","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"shasum":"063a65094622b4451ecf9814734c2b6ca85c33c4","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-2.0.1.tgz","integrity":"sha512-+K3P4Ydd/+xAgA1QPcwsze1flK2/l6jlDaUE5rbQFITWODHdep/l7uIMnTcNBaq6hTRzLka5LrH4qpry7OI2OQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCyQMfs2KSFt608DDlzckypbFT3VS+ArNFoza7o9ySCxQIgefaiFMR6Kca5WxhkLlIH9nkgIvbBKUEoJtUMxBYt3CU="}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/feather-route-matcher-2.0.1.tgz_1455491724588_0.5419196120928973"},"directories":{}},"3.0.0":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"3.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"standard":"^5.4.1","tap-spec":"^4.1.1","tape":"^4.2.2"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"test":"node test.js | tap-spec && standard"},"gitHead":"74947ed3b74a8b7d135e7e494beb8e2b7314763d","_id":"feather-route-matcher@3.0.0","_shasum":"b9d3041946fdea9d956e5b13dc5b8987be18e268","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.5","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"shasum":"b9d3041946fdea9d956e5b13dc5b8987be18e268","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-3.0.0.tgz","integrity":"sha512-axdHBDTVoUoKeRUW5hzHVS7etwSiBz648LD3KdiC52wIHwzqF24GS6XgOXWLcRKRie8FVZ2/DV3BVv71xCprgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDes/XgG/+Jeh5jKpQgLce7v19tMAZkbwDRBKP1Mg+aTAIhAI3LJA0s+tkblva9J1dS+kYRlSBk5YuK+FsJV1p+WMlx"}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/feather-route-matcher-3.0.0.tgz_1495163724722_0.020398552995175123"},"directories":{}},"3.1.0":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"3.1.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"rollup":"^1.12.2","rollup-plugin-commonjs":"^10.0.0","rollup-plugin-filesize":"^6.0.1","rollup-plugin-node-resolve":"^5.0.0","rollup-plugin-uglify":"^6.0.2","standard":"^12.0.1","tap-spec":"^5.0.0","tape":"^4.10.1"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"feather-route-matcher.js","module":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"build":"rollup -c","pretest":"npm run build","test":"node test.js | tap-spec && standard"},"standard":{"ignore":["feather-route-matcher.js","feather-route-matcher.min.js"]},"gitHead":"84efff1ea3d1fe697efdc3ca384adb1b52e0f955","_id":"feather-route-matcher@3.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"integrity":"sha512-06Dxu6nGBDz8gdzVmdEkQOZud9I0z9gQA5lkVg55gTRAj4zUbKw1TLpnuU41fGj2U5A9M+kVhEIS0CronIcuAA==","shasum":"84f1306285cc2e1c35dc8d569b471d24b94e054a","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-3.1.0.tgz","fileCount":9,"unpackedSize":27101,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdAQ28CRA9TVsSAnZWagAAekoP/AzYTZTsulwVbpYMtd7d\nBPYE7Dvw6Hl/TURi0csrK6wJFooLwZgaokKw3fRkUd/NKS/+RkcP6Domm4Lf\nSwTo9I3k2UsfIU85VTgMFxi7KDPl2EXDlssyhNkcP8AoLSgZ0orod7BpYxPt\nRAJ5eq7QNymL/IhwbQ1zyZ0JjAdxyoBa6hDhG/SitSzSbST2PWS4HY92tABE\nwkT7wrMzg42iy9GMXUwkgs8VlGX+5Ky2w8Y+WtWJkgOW81Ti7F5mQ7yUvume\nGmbZkrLYLK8b37OUYxWt18SET/s7AVq93/7SCLaEg6CcTdAM7fn0d3NPkKQR\n/lgFEm7CmmhnAnR//SjE8A/VyiiPrOhTv6+EjPsQeyoHJ3F1DrpYfohBebsk\nePQ+G5rdBPid+lPswAJeQD90+45cua36lzIYBsX1M7hrJHj9hw8AHWXjeLPU\nJDcNHyrOxK+Fqfqpp6EzJbtlfi/lyVvS2H4GU6O/ZRn5ED2+K6e3G5E6Qts7\n0YX4pD25YM1vlP2y+WGKfdp0vyqbLoVHA8J2ter6/AVU6UAF6GbqfjBa9i30\n2CSQLuZDUVo1hZpavK7fj1i+J73uFbD1WuuO+2PiD4O6+UaAi6GMGFRsW14O\nmCNF1KV1T9kZI9lvrRCubDaPmelpB3Wqt4m5ugDELTXALEj/ts2edBiZvQ6I\njogF\r\n=q6xN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCn1Gd+E8QoBhjHqOXXnDSIT3DognnAcuOIQt7zNOA5jQIhAJ1jSMkTsE349qD8ZFIUG3lxc3p27hYlnsqeS9arEs0g"}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feather-route-matcher_3.1.0_1560350140158_0.3888081790789162"},"_hasShrinkwrap":false},"4.0.0":{"name":"feather-route-matcher","description":"featherweight url to handler matching","version":"4.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"devDependencies":{"rollup":"2.10.5","rollup-plugin-commonjs":"10.1.0","rollup-plugin-filesize":"9.0.0","rollup-plugin-node-resolve":"5.2.0","rollup-plugin-uglify":"6.0.4","standard":"14.3.4","tap":"14.10.7","tap-spec":"5.0.0","tape":"5.0.0"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"license":"MIT","main":"feather-route-matcher.js","module":"index.js","repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"scripts":{"build":"rollup -c","pretest":"npm run build","test":"node test.js | tap-spec && standard"},"standard":{"ignore":["feather-route-matcher.js","feather-route-matcher.min.js"]},"prettier":{"semi":false,"singleQuote":true,"trailingComma":"none"},"gitHead":"9e94284af07b4dc20749ca33018dca10ce9477f3","_id":"feather-route-matcher@4.0.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.4","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"integrity":"sha512-ZBQx/3pMDnpjJi3zUDEhZ5Mvu+lUsTyWQoKH3tWEb0LysDZmzui0tH0oyMvA8fEWWJtHbvOzOpIWwoOBst/Apw==","shasum":"ab04f84cb78b28b58a8c8d009971e2f1016d3a27","tarball":"https://registry.npmjs.org/feather-route-matcher/-/feather-route-matcher-4.0.0.tgz","fileCount":9,"unpackedSize":27144,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexqAcCRA9TVsSAnZWagAA0WcP/Ru0eY7aLQAgLrW3210w\n5kRzW/gwErO/e6XfyDxzyDLheRU6ug+QR66sS0ND/RR6tFea5WWKwDL26aK/\nc5CJ2hdIK6CYXfc6pC5FZ5ltsLXjoKFKY63xbaMnsMK+KKUKP8BPL0GElxDn\nAvaMepPOpfb8ZLxUTO6X/fjRgC+DSXUJZ7Vq4SUIBH9PhLm3tXmUmw0h+NIy\n38em9Qg7+fBpdvuXPST1BuzY7a5N/2Z7rXoN2BaXA0/YOb8TdfPoimB3/qQg\nr4mwo+rSB4jRqcuCSyNjXSxkrAChZj1SRNN7IJuc3DVHUI4+fNMuQaVi8i9p\nGLNhyY3tQHIiIT26nvJsXXtLNQj2XYw6/dnkBwVyr8/xudoA0Mo65BdkTBl7\nOh4fF2Jp3V031zH86JwszXnXYA6sUW1mvxR2NKjIycaDIL2nsiJwDntmZm5t\nZz6E0bKCWj3LJFNu7UVjBE0YLs2v+0v8j3sq3fT02FZu/aWwGi+m7RcyDs02\n11LoZjQiHJ79uUJk+QQ0VQl38TvD3SuGMR/ILFChNXa5YlYWTESBaPm0G1Ky\nD6S3BUvlkUsR5T1um2i4YAsCOly8dpky3LXWFreBCFsKFGhFQBIHlEHYIQBM\ni61J+TtMpBdlMU3wukbce36pndd8ENDbWA+q1gwEdvtBMfFgyt55TDBkTkEh\nYREv\r\n=6LOf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCY148K0Ykdo82zRPPB0wMFTFG0eMa5e55NVUlFhaIzSAIgMUQxixDDWE49PNsk3fW0Oe5bgc9ftL584mbpITnflSk="}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feather-route-matcher_4.0.0_1590075420071_0.2747066075092457"},"_hasShrinkwrap":false}},"readme":"# feather-route-matcher\n\n![](https://img.shields.io/npm/dm/feather-route-matcher.svg)![](https://img.shields.io/npm/v/feather-route-matcher.svg)![](https://img.shields.io/npm/l/feather-route-matcher.svg)\n\nThis tiny module exports a single function that takes an object of url patterns and returns a function that can be called to get the matching object, based on the url.\n\nThis is in support of experiments I'm doing for building lightweight clientside apps [here](https://github.com/henrikjoreteg/feather-app).\n\nYou call `createMatcher` and pass it an object of routes where the key is the url pattern (using same matching logic as Backbone.js) and the result is whatever you want to return as a match to that url. Usually this would be a component representing the page you want to show for that url pattern, but it could be anything.\n\nYou could, for example, create a module that exports that function like this:\n\n**routes.js**\n\n```js\nimport createMatcher from 'feather-route-matcher'\nimport homePage from './pages/home'\nimport courseListingPage from './pages/course-listing'\nimport courseDetailPage from './pages/course-detail'\nimport notFoundPage from './pages/not-found'\n\nexport default createMatcher({\n  '/': homePage,\n  '/courses': courseListingPage,\n  '/courses/:id': courseDetailPage,\n  '/*': notFoundPage\n})\n```\n\nThis returns a function that can be called to retrieve the value, along with extracted parameters:\n\n**other.js**\n\n```js\nimport routeMatcher from './routes'\n\n// call it with a pathname you want to match\nrouteMatcher('/')\n// =>\n// {\n//   value: homePage,\n//   url: '/',\n//   params: null\n// }\n\nrouteMatcher('/courses/47')\n// =>\n// {\n//   value: courseDetailPage,\n//   url: '/',\n//   params: {\n//     id: '47'\n//   }\n// }\n\nrouteMatcher('/some-garbage')\n// =>\n// {\n//   value: notFoundPage,\n//   url: '/some/garbage',\n//   params: {\n//     // anything matched by a wildcard `*`\n//     // will return a param named `path`\n//     // with whatever existed in the location\n//     // where the `*` was\n//     path: 'some/garbage'\n//   }\n// }\n\n```\n\n## why is this useful?\n\nIf you treat the `url` in a clientside app as just another piece of application state in a frontend app you'll likely need some sort of `switch` statement or set of `if`/`else` blocks to match the current url with the component you want to show.\n\nThat's easy with urls that are known ahead of time, such as `/home` but becomes a bit more arduous when you want to see whether it matches a given pattern and want to extract values such as: `/user/42`. That's where this module helps with.\n\nThe result of the matcher is a great candidate for going into a state store, like [redux](http://redux.js.org/).\n\nThis module could be used as a really lightweight routing system for a react/redux app without the need for React Router.\n\n## how parameter extraction works\n\npattern: `'/users/:id'`\nurl: `'/something-else'`\nextracted params: nothing, because it won't match\n\npattern: `'/users/:id'`\nurl: `'/users/scrooge-mc-duck'`\nextracted params: `{id: 'scrooge-mc-duck'}`\n\npattern: `'/users/:id'`\nurl: `'/users/47'`\nextracted params: `{id: '47'}`\n\npattern: `'/schools/:schoolId/teachers/:teacherId'`\nurl: `'/schools/richland/teachers/47'`\nextracted params: `{schoolId: 'richland', teacherId: '47'}`\n\npattern: `*`\nurl: `'/asdfas'`\nextracted params: `{path: '/asdfas'}`\n**note:** extracted param always called `path`\n\npattern: `'/schools/*`\nurl: `'/schools/richland/teachers/47'`\nextracted params: `{path: 'richland/teachers/47'}`\n\n\n## Other notes\n\nThis module borrows a few extremely well-tested regexes from Backbone.js to do its pattern matching. Thanks for the generous licensing!\n\nThings to be aware of...\n\n1. Order is important, first match wins\n2. If you re-use parameter names in the url pattern they'll be overwritten in the result.\n3. If you need to parse query string values, match the base url first with this module, then use [`query-string`](http://npmjs.com/package/query-string) to parse query values.\n\n\n## install\n\n```\nnpm install feather-route-matcher --save\n```\n\n## credits\n\nIf you like this follow [@HenrikJoreteg](http://twitter.com/henrikjoreteg) on twitter. The regex patterns were borrowed from Backbone.js because they're extremely well tested and I want this to Just Work™.\n\n## tests\n\n```\nnpm run test\n```\n\n## changelog\n\n* `4.0.0` - Breaking changes: In the matched response, the property called `page` was renamed `value`. Removed `fallback` option because it's easy to do in app code using this. Fixed bug where passed in route object was being mutated.\n\n* `3.1.0` - Non-breaking conversion of `./index.js` into an esm module. umd version remains available as `./feather-route-matcher.js` and `./feather-route-matcher.min.js`\n\n* `3.0.0` - Changed result to now include the pattern that was matched as well.\n\n* `2.0.1` - Remove accidentally left ES6 usage.\n\n* `2.0.0` - Instead of expecting the values of object passed to `createMatcher` to be function of a certain structure, it now always just returns an object of a pre-determined structure, including the passed url, any extracted params, and a `page` key that contains whatever the original value of that key was.\n\n* `1.0.0` - initial release\n\n## license\n\n[MIT](http://mit.joreteg.com/)\n","maintainers":[{"name":"henrikjoreteg","email":"henrik@joreteg.com"}],"time":{"modified":"2022-06-17T23:56:18.244Z","created":"2015-12-15T03:37:44.497Z","1.0.0":"2015-12-15T03:37:44.497Z","2.0.0":"2016-02-13T06:42:26.330Z","2.0.1":"2016-02-14T23:15:26.427Z","3.0.0":"2017-05-19T03:15:27.586Z","3.1.0":"2019-06-12T14:35:40.284Z","4.0.0":"2020-05-21T15:37:00.186Z"},"homepage":"https://github.com/henrikjoreteg/feather-route-matcher","keywords":["feather","matcher","router","routing","url"],"repository":{"type":"git","url":"git://github.com/henrikjoreteg/feather-route-matcher.git"},"author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/henrikjoreteg/feather-route-matcher/issues"},"license":"MIT","readmeFilename":"README.md"}