Summary
createFetchRequest clones the incoming Request when fetch is called with an existing Request object, but it ignores the second init argument.
As a result, intercepted metadata can differ from the actual request that was sent.
Current behavior
For a call like this:
const base = new Request("https://example.com/base", { method: "GET" });
await fetch(base, { method: "POST", body: "payload" });
the interceptor sees the original GET request instead of the effective POST request.
Expected behavior
The intercepted Request should reflect the same effective request that fetch sends after applying init overrides.
Impact
matcher can evaluate against the wrong method, headers, or body
onIntercept can observe stale request data
- Consumers cannot rely on the intercepted
Request as a faithful representation of network traffic
Suggested acceptance criteria
createFetchRequest preserves the effective request semantics for fetch(Request, init)
- Unit tests cover method/body/header overrides when a
Request and init are both provided
Summary
createFetchRequestclones the incomingRequestwhenfetchis called with an existingRequestobject, but it ignores the secondinitargument.As a result, intercepted metadata can differ from the actual request that was sent.
Current behavior
For a call like this:
the interceptor sees the original
GETrequest instead of the effectivePOSTrequest.Expected behavior
The intercepted
Requestshould reflect the same effective request thatfetchsends after applyinginitoverrides.Impact
matchercan evaluate against the wrong method, headers, or bodyonInterceptcan observe stale request dataRequestas a faithful representation of network trafficSuggested acceptance criteria
createFetchRequestpreserves the effective request semantics forfetch(Request, init)Requestandinitare both provided