Skip to content

Commit

Permalink
fix: turn url parametes to camel case
Browse files Browse the repository at this point in the history
  • Loading branch information
zoubingwu committed Jan 1, 2022
1 parent 8eb444e commit a6810a0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"build": "tsup",
"fmt": "prettier {example,src,vite-plugin-msw-auto-mock}/**/*.{js,jsx,ts,tsx,css,md,html} --write",
"fmt": "prettier {example,src}/**/*.{js,jsx,ts,tsx,css,md,html} --write",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "zoubingwu<[email protected]>",
Expand All @@ -31,8 +31,10 @@
"swagger2openapi": "^7.0.8"
},
"devDependencies": {
"@types/lodash": "^4.14.178",
"@types/node": "^17.0.5",
"@types/prettier": "^2.4.2",
"lodash": "^4.17.21",
"openapi-types": "^10.0.0",
"tsup": "^5.11.9",
"typescript": "^4.5.4"
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
packages:
- example
- vite-plugin-auto-mock
7 changes: 4 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as prettier from 'prettier';
import * as path from 'path';
import camelCase from 'lodash/camelCase';

const EXTENSION_TO_PARSER: Record<string, string> = {
ts: 'typescript',
Expand Down Expand Up @@ -41,6 +42,6 @@ export async function prettify(
});
}

export const toExpressLikePath = (path: string) => {
return path.replace(/{(.+?)}/g, ':$1'); // use `.+?` for lazy match
};
export const toExpressLikePath = (path: string) =>
// use `.+?` for lazy match
path.replace(/{(.+?)}/g, (_match, p1: string) => `:${camelCase(p1)}`);

0 comments on commit a6810a0

Please sign in to comment.