Skip to content

Commit e7ae1d4

Browse files
committed
fix: proxy more parts of fetch Response
1 parent db982dd commit e7ae1d4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

addon/src/wait-for-fetch.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export async function waitForFetch(fetchPromise: ReturnType<typeof fetch>) {
55

66
return new Proxy(response, {
77
get(target, prop, receiver) {
8+
if (
9+
typeof prop === 'string' &&
10+
['ok', 'status', 'statusText', 'bodyUsed', 'headers', 'redirected', 'type', 'url'].includes(prop)
11+
) {
12+
return target[prop];
13+
}
814
const original = Reflect.get(target, prop, receiver);
915

1016
if (
@@ -15,7 +21,11 @@ export async function waitForFetch(fetchPromise: ReturnType<typeof fetch>) {
1521
return waitForPromise(original.call(target, ...args));
1622
};
1723
}
18-
24+
if (typeof prop === 'string' && ['clone'].includes(prop)) {
25+
return (...args) => {
26+
return original.call(target, ...args);
27+
}
28+
}
1929
return original;
2030
},
2131
});

0 commit comments

Comments
 (0)