Skip to content

Commit

Permalink
Deprecate URL and URLSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
charpeni committed Sep 18, 2021
1 parent be53728 commit 5fa7752
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Libraries/Blob/URL.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

const Blob = require('./Blob');
const warnOnce = require('../Utilities/warnOnce');

import NativeBlobModule from './NativeBlobModule';

Expand Down Expand Up @@ -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]));
}
Expand Down Expand Up @@ -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!');
}
Expand All @@ -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;
Expand Down

0 comments on commit 5fa7752

Please sign in to comment.