{"name":"egg-path-matching","version":"2.0.0","engine":{"node":">= 18.19.0"},"description":"match or ignore url path","scripts":{"lint":"eslint src test","test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","ci":"npm run lint && egg-bin cov && npm run prepublishOnly","contributor":"git-contributor","prepublishOnly":"tshy && tshy-after"},"keywords":["url","match","ignore"],"author":{"name":"dead-horse","email":"dead_horse@qq.com","url":"http://deadhorse.me"},"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/egg-path-matching.git"},"license":"MIT","dependencies":{"path-to-regexp":"^6.2.2"},"devDependencies":{"@eggjs/tsconfig":"1","@types/mocha":"10","@types/node":"20","egg-bin":"6","eslint":"8","eslint-config-egg":"13","git-contributor":"2","tshy":"1","tshy-after":"1","typescript":"5"},"type":"module","tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"exports":{"./package.json":"./package.json",".":{"import":{"source":"./src/index.ts","types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"source":"./src/index.ts","types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","_id":"egg-path-matching@2.0.0","gitHead":"6a3fb78cfa5edaa9e024ccb797549d156f63a727","bugs":{"url":"https://github.com/eggjs/egg-path-matching/issues"},"homepage":"https://github.com/eggjs/egg-path-matching#readme","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-08dMiPhQQPiH4k8vTImoCek3n9YR+/y4PAb2z/qllg7BeiOZaWl/lfi5dV7/2rw8FH3iC+AcMisF+GIp36ed9w==","shasum":"64881ccbcdbf6758ded1eb180182d51df17a96e1","tarball":"http://registry-npm.ywwl.com/egg-path-matching/download/egg-path-matching-2.0.0.tgz","fileCount":10,"unpackedSize":15383,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/egg-path-matching@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD5QgyResXgNy+daus7w3QcTKzdAXvB8nHo5capkCDT+QIgYGo2Ohe6i2ebOHFfTdiTdxYlZ1pDVoBusQsaD76JL58="}],"size":4644,"noattachment":false,"key":"/egg-path-matching/-/egg-path-matching-2.0.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-path-matching_2.0.0_1718465448659_0.6106608737211643"},"_hasShrinkwrap":false,"readme":"# egg-path-matching\n\n[![NPM version][npm-image]][npm-url]\n[![CI](https://github.com/eggjs/egg-path-matching/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-path-matching/actions/workflows/nodejs.yml)\n[![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg-path-matching.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg-path-matching)\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-path-matching.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-path-matching\n[snyk-image]: https://snyk.io/test/npm/egg-path-matching/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-path-matching\n[download-image]: https://img.shields.io/npm/dm/egg-path-matching.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-path-matching\n\n## Installation\n\n```bash\nnpm install egg-path-matching\n```\n\n## Usage\n\n```ts\nimport { pathMatching } from 'egg-path-matching';\n\nconst options = {\n  ignore: '/api', // string will use parsed by path-to-regexp\n  // support regexp\n  ignore: /^\\/api/,\n  // support function\n  ignore: ctx => ctx.path.startsWith('/api'),\n  // support Array\n  ignore: [ ctx => ctx.path.startsWith('/api'), /^\\/foo$/, '/bar'],\n  // support match or ignore\n  match: '/api',\n};\n\nconst match = pathMatching(options);\nassert.equal(match({ path: '/api' }), true);\nassert.equal(match({ path: '/api/hello' }), true);\nassert.equal(match({ path: '/api' }), true);\n```\n\n### options\n\n- `match` {String | RegExp | Function | Array} - if request path hit `options.match`, will return `true`, otherwise will return `false`.\n- `ignore` {String | RegExp | Function | Array} - if request path hit `options.ignore`, will return `false`, otherwise will return `true`.\n\n`ignore` and `match` can not both be presented.\nand if neither `ignore` nor `match` presented, the new function will always return `true`.\n\n### License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/7903541?v=4\" width=\"100px;\"/><br/><sub><b>releasethecow</b></sub>](https://github.com/releasethecow)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/227713?v=4\" width=\"100px;\"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/5102113?v=4\" width=\"100px;\"/><br/><sub><b>xyeric</b></sub>](https://github.com/xyeric)<br/>|\n| :---: | :---: | :---: | :---: | :---: |\n\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Dec 14 2023 17:20:14 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","publish_time":1718465448816,"_cnpm_publish_time":1718465448816,"dist-tags":{"latest":"2.1.0","release-1.x":"1.2.0"}}