{"id":22428329,"url":"https://github.com/momsfriendlydevco/path-match","last_synced_at":"2025-03-27T06:43:34.480Z","repository":{"id":213204463,"uuid":"733300588","full_name":"MomsFriendlyDevCo/path-match","owner":"MomsFriendlyDevCo","description":"Simple Express-like URL path matching","archived":false,"fork":false,"pushed_at":"2024-09-12T00:59:09.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T12:50:55.781Z","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/MomsFriendlyDevCo.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":"2023-12-19T02:44:59.000Z","updated_at":"2024-09-12T00:59:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a0679a6-83bb-4cff-ae17-571193a72023","html_url":"https://github.com/MomsFriendlyDevCo/path-match","commit_stats":null,"previous_names":["momsfriendlydevco/path-match"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpath-match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpath-match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpath-match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpath-match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/path-match/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798538,"owners_count":20673901,"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":[],"created_at":"2024-12-05T20:14:28.236Z","updated_at":"2025-03-27T06:43:34.455Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"@MomsFriendlyDevCo/path-match\n=============================\nExpress-like path matching module.\n\n\n* Supports various types - Path expressions, Regular Expression matching and functions\n* ... and array combinations of any of the above\n* ES6 compatible\n* Simple class/instance interface\n* Human readable `.toString()` method for debugging against each route\n* Optional route parameters - e.g. `/api/widgets/:id?`\n\n\n```javascript\nimport RoutePath, {compare, compile} from '@MomsFriendlyDevCo/path-match';\n\nlet rp1 = new RoutePath('/'); // or compile('/')\nrp1.isMatch('/') //= {}\nrp1.isMatch('/foo') //= false\n\nlet rp2 = new RoutePath('/api/widgets/:id');\nrp2.isMatch('/api/widgets') //= false\nrp2.isMatch('/api/widgets/123') //= {id: '123'}\n\nlet rp3 = new RoutePath('/api/doodads/:id?');\nrp3.isMatch('/api/doodads') //= {id: null}\nrp3.isMatch('/api/doodads/') //= {id: null}\nrp3.isMatch('/api/doodads/123') //= {id: '123'}\n\n// Or via shorthand methods:\ncompare('/api/widgets/:id', '/api/widgets'); //= false\ncompare('/api/widgets/:id', '/api/widgets/123'); //= {id: '123'}\n\n// Arrays of items\nlet rp4 = new RoutePath(['/foo', '/bar', '/baz']);\nrp4.isMatch('/bar') //= {}\nrp4.isMatch('/quz') //= false\n\n// Function matchers\nlet rp5 = new RoutePath([\n    '/foo',\n    (path) =\u003e path.startsWith('/bar'),\n    /^\\/baz\\/?$/i,\n]);\nrp5.isMatch('/FOO') //= {}\nrp5.isMatch('/bar') //= {}\nrp5.isMatch('/BAZ') //= {}\n```\n\n\nWhy?\n----\nBecause surprisingly, nearly all of the modules out there are either old (in some cases 7 years+), don't have adequate testkits, arn't ES6 compatible or just have an awful syntax.\n\n* [path-to-regexp](https://github.com/pillarjs/path-to-regexp) - The seminal NPM package, pretty old, no decent testkits to show proof-of-work and its syntax for extracting path segments is truly awful\n* [path-match](https://github.com/pillarjs/path-match) - Seems to work but will _always match_ even if the route doesn't resemble the input at all\n* ...about 100 different clones of path-to-regexp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fpath-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fpath-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fpath-match/lists"}