Skip to content

Commit

Permalink
[Mobile] Use react-native-url-polyfill in globals (#27867)
Browse files Browse the repository at this point in the history
* Use react-native-url-polyfill in globals

* Ensure we are using react-native-url-polyfill in native url tests

* Re-enable isURL fixture tests for mobile

* Update exclusions for lack of unicode support

* Remove native variant of is-url

This platform fork is no longer necessary, since we are using the
polyfill globally.
  • Loading branch information
mkevins authored Jan 8, 2021
1 parent adac5aa commit b3620b5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/react-native-editor/src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'react-native-get-random-values';
import jsdom from 'jsdom-jscore-rn';
import jsdomLevel1Core from 'jsdom-jscore-rn/lib/jsdom/level1/core';
import 'react-native-url-polyfill/auto';

/**
* WordPress dependencies
Expand Down
20 changes: 0 additions & 20 deletions packages/url/src/is-url.native.js

This file was deleted.

41 changes: 41 additions & 0 deletions packages/url/src/test/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Internal dependencies
*/
import './index.js';

/**
* External dependencies
*/
import 'react-native-url-polyfill/auto';

jest.mock( './fixtures/wpt-data.json', () => {
const data = jest.requireActual( './fixtures/wpt-data.json' );

/**
* Test items to exclude by input. Ideally this should be empty, but are
* necessary by non-spec-conformance of the Native implementations.
* Specifically, the React Native implementation uses an implementation of
* WHATWG URL without full Unicode support.
*
* @type {string[]}
*/
const URL_EXCEPTIONS = [
'https://�',
'https://%EF%BF%BD',
'http://a<b',
'http://a>b',
'http://a^b',
'non-special://a<b',
'non-special://a>b',
'non-special://a^b',
'ftp://example.com%80/',
'ftp://example.com%A0/',
'https://example.com%80/',
'https://example.com%A0/',
'file://­/p',
'file://%C2%AD/p',
'file://xn--/p',
];

return data.filter( ( { input } ) => ! URL_EXCEPTIONS.includes( input ) );
} );

0 comments on commit b3620b5

Please sign in to comment.