mock-fried 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
1
|
+
import { defineEventHandler, readBody, createError } from "h3";
|
|
2
|
+
import { parseQuery } from "ufo";
|
|
2
3
|
import { useRuntimeConfig } from "#imports";
|
|
3
4
|
import { readFileSync } from "node:fs";
|
|
4
5
|
import yaml from "js-yaml";
|
|
@@ -290,13 +291,15 @@ function handleClientPackageRequest(pkg, generator, cursorManager, pageManager,
|
|
|
290
291
|
export default defineEventHandler(async (event) => {
|
|
291
292
|
const config = useRuntimeConfig(event);
|
|
292
293
|
const mockConfig = config.mock;
|
|
293
|
-
const requestUrl = getRequestURL(event);
|
|
294
294
|
const prefix = mockConfig?.prefix || "/mock";
|
|
295
|
-
|
|
295
|
+
const fullPath = event.path;
|
|
296
|
+
const queryIndex = fullPath.indexOf("?");
|
|
297
|
+
let path = queryIndex >= 0 ? fullPath.substring(0, queryIndex) : fullPath;
|
|
298
|
+
const queryString = queryIndex >= 0 ? fullPath.substring(queryIndex + 1) : "";
|
|
296
299
|
if (path.startsWith(prefix)) {
|
|
297
300
|
path = path.substring(prefix.length) || "/";
|
|
298
301
|
}
|
|
299
|
-
const query =
|
|
302
|
+
const query = parseQuery(queryString);
|
|
300
303
|
let body;
|
|
301
304
|
if (event.method !== "GET" && event.method !== "HEAD") {
|
|
302
305
|
try {
|