Unverified Commit 16c53236 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Configure `url` for responses from patched fetch like the original `response.url` (#81507)

The main config that was missing is enumerability which is relevant for showing properties in the Chrome performance track and inferring shorthands.
parent e9877349
...@@ -27,6 +27,10 @@ export function cloneResponse(original: Response): [Response, Response] { ...@@ -27,6 +27,10 @@ export function cloneResponse(original: Response): [Response, Response] {
Object.defineProperty(cloned1, 'url', { Object.defineProperty(cloned1, 'url', {
value: original.url, value: original.url,
// How the original response.url behaves
configurable: true,
enumerable: true,
writable: false,
}) })
const cloned2 = new Response(body2, { const cloned2 = new Response(body2, {
...@@ -37,6 +41,10 @@ export function cloneResponse(original: Response): [Response, Response] { ...@@ -37,6 +41,10 @@ export function cloneResponse(original: Response): [Response, Response] {
Object.defineProperty(cloned2, 'url', { Object.defineProperty(cloned2, 'url', {
value: original.url, value: original.url,
// How the original response.url behaves
configurable: true,
enumerable: true,
writable: false,
}) })
return [cloned1, cloned2] return [cloned1, cloned2]
......
...@@ -29,9 +29,13 @@ describe('react-performance-track', () => { ...@@ -29,9 +29,13 @@ describe('react-performance-track', () => {
expect(track).toEqual( expect(track).toEqual(
expect.arrayContaining([ expect.arrayContaining([
{ {
// TODO: Should include the URL. // React might decide to display the shorthand in round brackets differently.
name: 'fetch', // Double check with React changes if a shorthand change is intended.
properties: expect.arrayContaining([['status', '200']]), name: 'fetch (random)',
properties: expect.arrayContaining([
['status', '200'],
['url', '"https://next-data-api-endpoint.vercel.app/api/random"'],
]),
}, },
]) ])
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment