{"id":16698051,"url":"https://github.com/arlac77/multi-path-matcher","last_synced_at":"2025-03-21T19:32:29.235Z","repository":{"id":35051231,"uuid":"200808243","full_name":"arlac77/multi-path-matcher","owner":"arlac77","description":"finds and decodes best matching path","archived":false,"fork":false,"pushed_at":"2024-10-27T18:54:37.000Z","size":2634,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-28T08:17:35.951Z","etag":null,"topics":["path-to-regexp","routing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arlac77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-06T08:20:59.000Z","updated_at":"2024-10-27T18:21:54.000Z","dependencies_parsed_at":"2023-09-21T23:21:40.265Z","dependency_job_id":"1fe5a84a-ab2f-4502-ba42-6cc6bd399712","html_url":"https://github.com/arlac77/multi-path-matcher","commit_stats":{"total_commits":1124,"total_committers":7,"mean_commits":"160.57142857142858","dds":"0.24555160142348753","last_synced_commit":"3c375d17f4c61df75e6aa1236746f5adbcb89abd"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fmulti-path-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fmulti-path-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fmulti-path-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fmulti-path-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arlac77","download_url":"https://codeload.github.com/arlac77/multi-path-matcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221818085,"owners_count":16885684,"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","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":["path-to-regexp","routing"],"created_at":"2024-10-12T17:50:32.584Z","updated_at":"2025-03-21T19:32:29.214Z","avatar_url":"https://github.com/arlac77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/multi-path-matcher.svg)](https://www.npmjs.com/package/multi-path-matcher)\n[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)\n[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\\\u0026label\\\u0026labelColor=blue\\\u0026color=555555)](https://typescriptlang.org)\n[![bundlejs](https://deno.bundlejs.com/?q=multi-path-matcher\\\u0026badge=detailed)](https://bundlejs.com/?q=multi-path-matcher)\n[![downloads](http://img.shields.io/npm/dm/multi-path-matcher.svg?style=flat-square)](https://npmjs.org/package/multi-path-matcher)\n[![GitHub Issues](https://img.shields.io/github/issues/arlac77/multi-path-matcher.svg?style=flat-square)](https://github.com/arlac77/multi-path-matcher/issues)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fmulti-path-matcher%2Fbadge\\\u0026style=flat)](https://actions-badge.atrox.dev/arlac77/multi-path-matcher/goto)\n[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/multi-path-matcher/badge.svg)](https://snyk.io/test/github/arlac77/multi-path-matcher)\n[![Coverage Status](https://coveralls.io/repos/arlac77/multi-path-matcher/badge.svg)](https://coveralls.io/github/arlac77/multi-path-matcher)\n\n# multi-path-matcher\n\nFinds and decodes best matching path in a set of routes\n\n# usage\n\nWith params\n\n```js\nimport { compile, matcher } from \"multi-path-matcher\";\n\nconst routes = [\n  { path: \"/a/b/c\" },\n  { path: \"/a/b\" },\n  { path: \"/d/:att1/e/:att2\" },\n  { path: \"/d/:att1/e\" },\n  { path: \"/\" }\n];\n\nconst compiled = compile(routes);\n\nmatcher(compiled \"/a\");                   // undefined\nmatcher(compiled, \"/a/b\");                // routes[1]\nmatcher(compiled, \"/a/b/c\");              // routes[0]\nmatcher(compiled, \"/d/value1/e\");                 // routes[3] { att1: \"value1\" }\nmatcher(compiled, \"/d/value1/e/value2?sort=asc\"); // routes[2] { att1: \"value1\", att2: \"value2\" }\nmatcher(compiled, \"/\");                           // routes[4]\n```\n\nWith wildcards\n\n```js\nimport { compile, matcher } from \"multi-path-matcher\";\n\nconst routes = [\n  { path: \"/\" },\n  { path: \"/*\" },\n  { path: \"/about\" },\n  { path: \"/login\" }\n];\n\nconst compiled = compile(routes);\n\nmatcher(compiled, \"/\");                   // routes[0]\nmatcher(compiled, \"/index.html\");         // routes[1]\nmatcher(compiled, \"/about\");              // routes[2]\nmatcher(compiled, \"/login?param=1\");      // routes[3]\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [Route](#route)\n    *   [Properties](#properties)\n*   [CompiledRoute](#compiledroute)\n    *   [Properties](#properties-1)\n*   [Match](#match)\n    *   [Properties](#properties-2)\n*   [PLAIN](#plain)\n*   [WILDCARD](#wildcard)\n*   [PARAM](#param)\n*   [compile](#compile)\n    *   [Parameters](#parameters)\n*   [pathToRegexp](#pathtoregexp)\n    *   [Parameters](#parameters-1)\n*   [matcher](#matcher)\n    *   [Parameters](#parameters-2)\n\n## Route\n\nOne single route\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n\n## CompiledRoute\n\nResult of a path compilation\npriorities for each path component\n\n*   :param       [PARAM](#param)\n*   match \\* or ? [WILDCARD](#wildcard)\n*   plain        [PLAIN](#plain)\n\nType: [Route](#route)\n\n### Properties\n\n*   `regex` **[RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp)** for later checking and params extraction\n*   `keys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** all keys found in the route\n*   `priority` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** order in which to check\n\n## Match\n\nResult of a match\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `route` **[Route](#route)?** as given to the compiler, undefined if no matching route was found\n*   `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** extracted from the path\n\n## PLAIN\n\nPrioritiy for a plain path component\n\nType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\n\n## WILDCARD\n\nPrioritiy for a path component with a wildcard '\\*'\n\nType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\n\n## PARAM\n\nPrioritiy for a parameter path component\n\nType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)\n\n## compile\n\nCompile a set of routes.\nAll properties of the original routes are preserved\n\n### Parameters\n\n*   `routes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[Route](#route)\u003e**\u0026#x20;\n\nReturns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[CompiledRoute](#compiledroute)\u003e**\u0026#x20;\n\n## pathToRegexp\n\nGenerate regex with priority.\n\n### Parameters\n\n*   `route` **[Route](#route)**\u0026#x20;\n\nReturns **[CompiledRoute](#compiledroute)**\u0026#x20;\n\n## matcher\n\nFind best match for a given path.\nDecodes params into an object.\n\n### Parameters\n\n*   `compiled` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[CompiledRoute](#compiledroute)\u003e**\u0026#x20;\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n\nReturns **[Match](#match)** match\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```shell\nnpm install multi-path-matcher\n```\n\n# license\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fmulti-path-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farlac77%2Fmulti-path-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fmulti-path-matcher/lists"}