From 5fa77525760ab5448c25d6d9b810c56995cb90a1 Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Thu, 15 Oct 2020 16:40:02 -0400 Subject: [PATCH 1/2] Deprecate URL and URLSearchParams --- Libraries/Blob/URL.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 3e63ff753fa179..a28277cb0924c6 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -8,6 +8,7 @@ */ const Blob = require('./Blob'); +const warnOnce = require('../Utilities/warnOnce'); import NativeBlobModule from './NativeBlobModule'; @@ -55,6 +56,13 @@ export class URLSearchParams { _searchParams = []; constructor(params: any) { + warnOnce( + 'urlsearchparams-deprecated', + 'URLSearchParams from React Native has been deprecated and will be removed in a future release. ' + + "It can now be installed from 'react-native-url-polyfill'. " + + 'See https://github.com/charpeni/react-native-url-polyfill', + ); + if (typeof params === 'object') { Object.keys(params).forEach(key => this.append(key, params[key])); } @@ -114,6 +122,13 @@ export class URL { _searchParamsInstance = null; static createObjectURL(blob: Blob) { + warnOnce( + 'url-deprecated', + 'URL from React Native has been deprecated and will be removed in a future release. ' + + "It can now be installed from 'react-native-url-polyfill'. " + + 'See https://github.com/charpeni/react-native-url-polyfill', + ); + if (BLOB_URL_PREFIX === null) { throw new Error('Cannot create URL for blob!'); } @@ -125,6 +140,13 @@ export class URL { } constructor(url: string, base: string) { + warnOnce( + 'url-deprecated', + 'URL from React Native has been deprecated and will be removed in a future release. ' + + "It can now be installed from 'react-native-url-polyfill'. " + + 'See https://github.com/charpeni/react-native-url-polyfill', + ); + let baseUrl = null; if (!base || validateBaseUrl(url)) { this._url = url; From e2421b6d9d8d6bedc184c34938c048361f5fe947 Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Sat, 18 Sep 2021 17:38:03 -0400 Subject: [PATCH 2/2] Rewrote the message to warn instead of deprecating --- Libraries/Blob/URL.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index a28277cb0924c6..d53704ca260cdc 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -57,9 +57,9 @@ export class URLSearchParams { constructor(params: any) { warnOnce( - 'urlsearchparams-deprecated', - 'URLSearchParams from React Native has been deprecated and will be removed in a future release. ' + - "It can now be installed from 'react-native-url-polyfill'. " + + 'urlsearchparams-warn-non-spec-compliant', + 'URLSearchParams from React Native is not spec-compliant. ' + + "You should use a spec-compliant polyfill like 'react-native-url-polyfill'. " + 'See https://github.com/charpeni/react-native-url-polyfill', ); @@ -123,9 +123,9 @@ export class URL { static createObjectURL(blob: Blob) { warnOnce( - 'url-deprecated', - 'URL from React Native has been deprecated and will be removed in a future release. ' + - "It can now be installed from 'react-native-url-polyfill'. " + + 'url-warn-non-spec-compliant', + 'URL from React Native is not spec-compliant. ' + + "You should use a spec-compliant polyfill like 'react-native-url-polyfill'. " + 'See https://github.com/charpeni/react-native-url-polyfill', ); @@ -141,9 +141,9 @@ export class URL { constructor(url: string, base: string) { warnOnce( - 'url-deprecated', - 'URL from React Native has been deprecated and will be removed in a future release. ' + - "It can now be installed from 'react-native-url-polyfill'. " + + 'url-warn-non-spec-compliant', + 'URL from React Native is not spec-compliant. ' + + "You should use a spec-compliant polyfill like 'react-native-url-polyfill'. " + 'See https://github.com/charpeni/react-native-url-polyfill', );