{"id":13527640,"url":"https://github.com/lukeed/matchit","last_synced_at":"2025-10-09T18:23:30.783Z","repository":{"id":46272929,"uuid":"109605518","full_name":"lukeed/matchit","owner":"lukeed","description":"Quickly parse \u0026 match URLs","archived":false,"fork":false,"pushed_at":"2021-11-03T06:37:51.000Z","size":52,"stargazers_count":323,"open_issues_count":3,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-06T23:28:20.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T18:37:41.000Z","updated_at":"2025-07-23T21:23:08.000Z","dependencies_parsed_at":"2022-08-30T21:01:10.408Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/matchit","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/lukeed/matchit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmatchit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmatchit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmatchit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmatchit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/matchit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fmatchit/sbom","scorecard":{"id":604491,"data":{"date":"2025-08-11","repo":{"name":"github.com/lukeed/matchit","commit":"dd17b00e133e7383571e5aa793570700f3ebd2d8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":1,"reason":"Found 4/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.md:0","Info: FSF or OSI recognized license: MIT License: license.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T01:15:51.645Z","repository_id":46272929,"created_at":"2025-08-21T01:15:51.645Z","updated_at":"2025-08-21T01:15:51.645Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001940,"owners_count":26083226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:55.137Z","updated_at":"2025-10-09T18:23:30.755Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","readme":"# matchit [![Build Status](https://travis-ci.org/lukeed/matchit.svg?branch=master)](https://travis-ci.org/lukeed/matchit)\n\n\u003e Quickly parse \u0026 match URLs\n\n## Install\n\n```\n$ npm install --save matchit\n```\n\n\n## Usage\n\n```js\nconst { exec, match, parse } = require('matchit');\n\nparse('/foo/:bar/:baz?');\n//=\u003e [\n//=\u003e   { old:'/foo/:bar', type:0, val:'foo' },\n//=\u003e   { old:'/foo/:bar', type:1, val:'bar' },\n//=\u003e   { old:'/foo/:bar', type:3, val:'baz' }\n//=\u003e ]\n\nconst routes = ['/', '/foo', 'bar', '/baz', '/baz/:title','/bat/*'].map(parse);\n\nmatch('/', routes);\n//=\u003e [{ old:'/', type:0, val:'/' }]\n\nmatch('/foo', routes);\n//=\u003e [{ old:'/foo', type:0, val:'foo' }]\n\nmatch('/bar', routes);\n//=\u003e [{ old:'bar', type:0, val:'bar' }]\n\nmatch('/baz', routes);\n//=\u003e [{ old:'/baz', type:0, val:'baz' }]\n\nlet a = match('/baz/hello', routes);\n//=\u003e [{...}, {...}]\nlet b = exec('/baz/hello', a);\n//=\u003e { title:'hello' }\n\nmatch('/bat/quz/qut', routes);\n//=\u003e [\n//=\u003e   { old:'/bat/*', type:0, val:'bat' },\n//=\u003e   { old:'/bat/*', type:2, val:'*' }\n//=\u003e ]\n```\n\n\n## API\n\n### matchit.parse(route)\n\nReturns: `Array`\n\nThe `route` is `split` and parsed into a \"definition\" array of objects. Each object (\"segment\") contains a `val`, `type`, and `old` key:\n\n* `old` \u0026mdash; The [`route`](#route)'s original value\n* `type` \u0026mdash; An numerical representation of the segment type.\n    * `0` - static\n    * `1` - parameter\n    * `2` - any/wildcard\n    * `3` - optional param\n* `val` \u0026mdash; The current segment's value. This is either a static value of the name of a parameter\n\n#### route\n\nType: `String`\n\nA single URL pattern.\n\n\u003e **Note:** Input will be stripped of all leading \u0026 trailing `/` characters, so there's no need to normalize your own URLs before passing it to `parse`!\n\n\n### matchit.match(url, routes)\n\nReturns: `Array`\n\nReturns the [`route`](#route)'s encoded definition. See [`matchit.parse`](#matchitparseroute).\n\n#### url\n\nType: `String`\n\nThe true URL you want to be matched.\n\n#### routes\n\nType: `Array`\n\n_All_ \"parsed\" route definitions, via [`matchit.parse`](#matchitparseroute).\n\n\u003e **Important:** Multiple routes will require an Array of `matchit.parse` outputs.\n\n\n### matchit.exec(url, match)\n\nReturns: `Object`\n\nReturns an object an object of `key:val` pairs, as defined by your [`route`](#route) pattern.\n\n#### url\n\nType: `String`\n\nThe URL (`pathname`) to evaluate.\n\n\u003e **Important:** This should be `pathname`s only as any `querystring`s will be included the response.\n\n#### match\n\nType: `Array`\n\nThe route definition to use, via [`matchit.match`](#matchitmatchurl-routes).\n\n\n## Benchmarks\n\n\u003e Running Node v10.13.0\n\n```\n# Parsing\n  matchit               x 1,489,482 ops/sec ±2.89% (97 runs sampled)\n  regexparam            x   406,824 ops/sec ±1.38% (96 runs sampled)\n  path-to-regexp        x    83,439 ops/sec ±0.89% (96 runs sampled)\n  path-to-regexp.parse  x   421,266 ops/sec ±0.13% (97 runs sampled)\n\n# Match (index)\n  matchit                x 132,338,546 ops/sec ±0.14% (96 runs sampled)\n  regexparam             x  49,889,162 ops/sec ±0.21% (95 runs sampled)\n  path-to-regexp.exec    x   7,176,721 ops/sec ±1.23% (94 runs sampled)\n  path-to-regexp.tokens  x     102,021 ops/sec ±0.21% (96 runs sampled)\n\n# Match (param)\n  matchit                x 2,700,618 ops/sec ±0.92% (95 runs sampled)\n  regexparam             x 6,924,653 ops/sec ±0.33% (94 runs sampled)\n  path-to-regexp.exec    x 4,715,483 ops/sec ±0.28% (96 runs sampled)\n  path-to-regexp.tokens  x    98,182 ops/sec ±0.45% (93 runs sampled)\n\n# Match (optional)\n  matchit                x 2,816,313 ops/sec ±0.64% (93 runs sampled)\n  regexparam             x 8,437,064 ops/sec ±0.41% (93 runs sampled)\n  path-to-regexp.exec    x 5,909,510 ops/sec ±0.22% (97 runs sampled)\n  path-to-regexp.tokens  x   101,832 ops/sec ±0.43% (98 runs sampled)\n\n# Match (wildcard)\n  matchit                x 3,409,100 ops/sec ±0.34% (98 runs sampled)\n  regexparam             x 9,740,429 ops/sec ±0.49% (95 runs sampled)\n  path-to-regexp.exec    x 8,740,590 ops/sec ±0.43% (89 runs sampled)\n  path-to-regexp.tokens  x   102,109 ops/sec ±0.35% (96 runs sampled)\n\n# Exec\n  matchit         x 1,558,321 ops/sec ±0.33% (96 runs sampled)\n  regexparam      x 6,966,297 ops/sec ±0.21% (97 runs sampled)\n  path-to-regexp  x   102,250 ops/sec ±0.45% (95 runs sampled)\n```\n\n## Related\n\n- [regexparam](https://github.com/lukeed/regexparam) - A similar (285B) utility, but relies on `RegExp` instead of String comparisons.\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","funding_links":[],"categories":["JavaScript","目录","Routers and URL Utils","Packages"],"sub_categories":["Reactive Programming","HTTP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fmatchit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fmatchit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fmatchit/lists"}