{"id":13779870,"url":"https://github.com/koajs/rewrite","last_synced_at":"2025-04-05T18:09:50.531Z","repository":{"id":53148893,"uuid":"12704944","full_name":"koajs/rewrite","owner":"koajs","description":"URL rewriting middleware","archived":false,"fork":false,"pushed_at":"2024-09-16T00:22:04.000Z","size":22,"stargazers_count":98,"open_issues_count":4,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T15:32:18.174Z","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/koajs.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","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":"2013-09-09T15:24:13.000Z","updated_at":"2024-10-11T12:11:36.000Z","dependencies_parsed_at":"2024-11-06T08:40:34.535Z","dependency_job_id":null,"html_url":"https://github.com/koajs/rewrite","commit_stats":{"total_commits":24,"total_committers":12,"mean_commits":2.0,"dds":0.7916666666666666,"last_synced_commit":"2c6ce829efa6e28265eb28654be91fa122f496ac"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Frewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Frewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Frewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Frewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koajs","download_url":"https://codeload.github.com/koajs/rewrite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246893294,"owners_count":20850924,"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-08-03T18:01:10.045Z","updated_at":"2025-04-05T18:09:50.508Z","avatar_url":"https://github.com/koajs.png","language":"JavaScript","readme":"# [**koa-rewrite**](https://github.com/koajs/rewrite)\n\n\u003e URL rewrite middleware for koa.\n\n___Notice: `koa-rewrite@2+` supports `koa@2`, if you want to use this module with `koa@1`, please use `koa-rewrite@1`.___\n\n\n## Installation\n\n```js\n$ npm install koa-rewrite\n```\n\n\n## Examples\n\nRewrite using a regular expression, rewriting `/i123` to `/items/123`.\n\n```js\napp.use(rewrite(/^\\/i(\\w+)/, '/items/$1'));\n```\n\nRewrite using route parameters, references may be named or numeric. For example rewrite `/foo..bar` to `/commits/foo/to/bar`:\n\n```js\napp.use(rewrite('/:src..:dst', '/commits/$1/to/$2'));\napp.use(rewrite('/:src..:dst', '/commits/:src/to/:dst'));\n```\n\nYou may also use the wildcard `*` to soak up several segments, for example `/js/vendor/jquery.js` would become `/public/assets/js/vendor/jquery.js`:\n\n```js\napp.use(rewrite('/js/(.*)', '/public/assets/js/$1'));\n```\n\n\n## Debugging\n\nUse the __DEBUG__ environment variable with \"koa-rewrite\":\n\n```\nkoa-rewrite rewrite /i123 -\u003e /items/123 +762ms\nkoa-rewrite rewrite /i321 -\u003e /items/321 +9s\nkoa-rewrite rewrite /i123 -\u003e /items/123 +5s\n```\n\n\n## License\n\n[MIT](/LICENSE)","funding_links":[],"categories":["Middleware","仓库","JavaScript"],"sub_categories":["中间件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Frewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoajs%2Frewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Frewrite/lists"}