chore: bump version to 0.0.36, update rollup to 4.55.3, and modify adapter URL handling
This commit is contained in:
@@ -60,15 +60,27 @@ export const adapter = async (opts: AdapterOpts = {}, overloadOpts?: RequestInit
|
||||
if (opts?.url?.startsWith('http')) {
|
||||
url = new URL(opts.url);
|
||||
} else {
|
||||
origin = window?.location?.origin || 'http://localhost:51015';
|
||||
origin = window?.location?.origin || 'http://localhost:51515';
|
||||
url = new URL(opts.url, origin);
|
||||
}
|
||||
const isGet = method === 'GET';
|
||||
if (isGet) {
|
||||
url.search = new URLSearchParams(opts.body as SimpleObject).toString();
|
||||
let searchParams = new URLSearchParams(opts.body as SimpleObject);
|
||||
url.search = searchParams.toString();
|
||||
} else {
|
||||
const params = opts.params || {};
|
||||
url.search = new URLSearchParams(params as SimpleObject).toString();
|
||||
const searchParams = new URLSearchParams(params as SimpleObject);
|
||||
if (typeof opts.body === 'object' && opts.body !== null) {
|
||||
// 浏览器环境下,自动将 body 中的 path 和 key 提取到查询参数中, 更容易排查问题
|
||||
let body = opts.body as Record<string, any> || {};
|
||||
if (!params.path && body?.path) {
|
||||
params.path = body.path;
|
||||
if (body?.key) {
|
||||
params.key = body.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
url.search = searchParams.toString();
|
||||
}
|
||||
let body: string | FormData | undefined = undefined;
|
||||
if (isGet) {
|
||||
|
||||
Reference in New Issue
Block a user