Skip to content

Commit

Permalink
fix: ensure that the URLs of different request methods cannot match c…
Browse files Browse the repository at this point in the history
…lose #6
  • Loading branch information
vben-admin committed Mar 9, 2021
1 parent 4474a2e commit efe943d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-mock",
"version": "2.2.2",
"version": "2.2.3",
"description": "A mock plugin for vite",
"main": "dist/index.js",
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/createMockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function requestMiddle(opt: ViteMockOptions) {

const reqUrl = isGet ? queryParams.pathname : req.url;
const matchReq = mockData.find((item) => {
if (item.method && item.method.toUpperCase() !== req.method) return false;
if (!reqUrl) return false;
return pathToRegexp(item.url).test(reqUrl);
});
Expand Down

0 comments on commit efe943d

Please sign in to comment.