From 39a44009ab0c5660398a1f235e183005c31c3e96 Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Thu, 17 Aug 2023 17:47:20 -0400 Subject: [PATCH 1/5] Update error decoder URL --- packages/shared/__tests__/ReactError-test.internal.js | 2 +- .../shared/__tests__/ReactErrorProd-test.internal.js | 6 +++--- packages/shared/formatProdErrorMessage.js | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/shared/__tests__/ReactError-test.internal.js b/packages/shared/__tests__/ReactError-test.internal.js index 9411616fa3c93..ba25cfdab3e6b 100644 --- a/packages/shared/__tests__/ReactError-test.internal.js +++ b/packages/shared/__tests__/ReactError-test.internal.js @@ -41,7 +41,7 @@ describe('ReactError', () => { it('should error with minified error code', () => { expect(() => ReactDOM.render('Hi', null)).toThrowError( 'Minified React error #200; visit ' + - 'https://reactjs.org/docs/error-decoder.html?invariant=200' + + 'https://react.dev/errors/200' + ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.', ); diff --git a/packages/shared/__tests__/ReactErrorProd-test.internal.js b/packages/shared/__tests__/ReactErrorProd-test.internal.js index be40f7b6d43cc..83eb16d9579f8 100644 --- a/packages/shared/__tests__/ReactErrorProd-test.internal.js +++ b/packages/shared/__tests__/ReactErrorProd-test.internal.js @@ -19,21 +19,21 @@ describe('ReactErrorProd', () => { it('should throw with the correct number of `%s`s in the URL', () => { expect(formatProdErrorMessage(124, 'foo', 'bar')).toEqual( 'Minified React error #124; visit ' + - 'https://reactjs.org/docs/error-decoder.html?invariant=124&args[]=foo&args[]=bar' + + 'https://react.dev/errors/124?args[]=foo&args[]=bar' + ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.', ); expect(formatProdErrorMessage(20)).toEqual( 'Minified React error #20; visit ' + - 'https://reactjs.org/docs/error-decoder.html?invariant=20' + + 'https://react.dev/errors/20' + ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.', ); expect(formatProdErrorMessage(77, '
', '&?bar')).toEqual( 'Minified React error #77; visit ' + - 'https://reactjs.org/docs/error-decoder.html?invariant=77&args[]=%3Cdiv%3E&args[]=%26%3Fbar' + + 'https://react.dev/errors/77?args[]=%3Cdiv%3E&args[]=%26%3Fbar' + ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.', ); diff --git a/packages/shared/formatProdErrorMessage.js b/packages/shared/formatProdErrorMessage.js index 91af4b114e585..a890d33ee262d 100644 --- a/packages/shared/formatProdErrorMessage.js +++ b/packages/shared/formatProdErrorMessage.js @@ -11,10 +11,14 @@ // during build. function formatProdErrorMessage(code) { - let url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code; - for (let i = 1; i < arguments.length; i++) { - url += '&args[]=' + encodeURIComponent(arguments[i]); + let url = 'https://react.dev/errors/' + code; + if (arguments.length > 1) { + url += '?args[]=' + encodeURIComponent(arguments[1]); + for (let i = 2; i < arguments.length; i++) { + url += '&args[]=' + encodeURIComponent(arguments[i]); + } } + return ( `Minified React error #${code}; visit ${url} for the full message or ` + 'use the non-minified dev environment for full errors and additional ' + From b7efd53e196ac759602350a1401e8267e66816cc Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Thu, 17 Aug 2023 19:00:41 -0400 Subject: [PATCH 2/5] Fix tests --- scripts/jest/setupTests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js index ddd1c2a03268d..733c201d79210 100644 --- a/scripts/jest/setupTests.js +++ b/scripts/jest/setupTests.js @@ -169,7 +169,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { if (!message) { return message; } - const re = /error-decoder.html\?invariant=(\d+)([^\s]*)/; + const re = /react.dev\/errors\/(\d+)?([^\s]*)/; const matches = message.match(re); if (!matches || matches.length !== 3) { return message; From e310da0ba797f33501e09303235fa57272596635 Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Wed, 17 Jan 2024 16:57:03 -0500 Subject: [PATCH 3/5] Fix decode error message --- scripts/jest/setupTests.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js index 733c201d79210..5a25cf4d74455 100644 --- a/scripts/jest/setupTests.js +++ b/scripts/jest/setupTests.js @@ -169,7 +169,8 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { if (!message) { return message; } - const re = /react.dev\/errors\/(\d+)?([^\s]*)/; + console.log('message', message); + const re = /react.dev\/errors\/(\d+)?\?([^\s]*)/; const matches = message.match(re); if (!matches || matches.length !== 3) { return message; From 0d415bb0d81d9da79cc870b58de47d1ffc76932d Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Wed, 17 Jan 2024 18:24:15 -0500 Subject: [PATCH 4/5] rm log --- scripts/jest/setupTests.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js index 5a25cf4d74455..fbeae6fc5c0b2 100644 --- a/scripts/jest/setupTests.js +++ b/scripts/jest/setupTests.js @@ -169,7 +169,6 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { if (!message) { return message; } - console.log('message', message); const re = /react.dev\/errors\/(\d+)?\?([^\s]*)/; const matches = message.match(re); if (!matches || matches.length !== 3) { From e42d72b976bca8ec32a98c12021fe3d85edb1cd8 Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Wed, 17 Jan 2024 20:15:35 -0500 Subject: [PATCH 5/5] Fix regex again --- scripts/jest/setupTests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jest/setupTests.js b/scripts/jest/setupTests.js index fbeae6fc5c0b2..f4db355d43968 100644 --- a/scripts/jest/setupTests.js +++ b/scripts/jest/setupTests.js @@ -169,7 +169,7 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { if (!message) { return message; } - const re = /react.dev\/errors\/(\d+)?\?([^\s]*)/; + const re = /react.dev\/errors\/(\d+)?\??([^\s]*)/; const matches = message.match(re); if (!matches || matches.length !== 3) { return message;