mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:18:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -14,8 +14,12 @@ function withDuplex(
|
||||
typeof Request !== "undefined" &&
|
||||
input instanceof Request &&
|
||||
input.body != null;
|
||||
if (!hasInitBody && !hasRequestBody) return init;
|
||||
if (init && "duplex" in (init as Record<string, unknown>)) return init;
|
||||
if (!hasInitBody && !hasRequestBody) {
|
||||
return init;
|
||||
}
|
||||
if (init && "duplex" in (init as Record<string, unknown>)) {
|
||||
return init;
|
||||
}
|
||||
return init
|
||||
? ({ ...init, duplex: "half" as const } as RequestInitWithDuplex)
|
||||
: ({ duplex: "half" as const } as RequestInitWithDuplex);
|
||||
@@ -25,7 +29,9 @@ export function wrapFetchWithAbortSignal(fetchImpl: typeof fetch): typeof fetch
|
||||
const wrapped = ((input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const patchedInit = withDuplex(init, input);
|
||||
const signal = patchedInit?.signal;
|
||||
if (!signal) return fetchImpl(input, patchedInit);
|
||||
if (!signal) {
|
||||
return fetchImpl(input, patchedInit);
|
||||
}
|
||||
if (typeof AbortSignal !== "undefined" && signal instanceof AbortSignal) {
|
||||
return fetchImpl(input, patchedInit);
|
||||
}
|
||||
@@ -62,6 +68,8 @@ export function wrapFetchWithAbortSignal(fetchImpl: typeof fetch): typeof fetch
|
||||
|
||||
export function resolveFetch(fetchImpl?: typeof fetch): typeof fetch | undefined {
|
||||
const resolved = fetchImpl ?? globalThis.fetch;
|
||||
if (!resolved) return undefined;
|
||||
if (!resolved) {
|
||||
return undefined;
|
||||
}
|
||||
return wrapFetchWithAbortSignal(resolved);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user