Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This gets automatically expanded into
// imports that only pick what we need
import '@babel/polyfill'
// Polyfill URL because Chrome and Firefox are not spec-compliant
// Hostnames of URIs with custom schemes (e.g. git) are not parsed out
import { URL, URLSearchParams } from 'whatwg-url'
// The polyfill does not expose createObjectURL, which we need for creating data: URIs for Web
// Workers. So retain it.
URL.createObjectURL = window.URL.createObjectURL
Object.assign(window, { URL, URLSearchParams })
* window.URL global object for URL parsing.
*
* RN provides a global URL object… but only puts two things into it.
*
* The JSDOM project maintains a browser-compatible URL module.
*
* Thus, we stick that into the global namespace, and monkey-patch RN's
* two non-standard methods onto it so as to not break either things that
* expect web!URL or RN!URL objects.
*/
import {URL, URLSearchParams} from 'whatwg-url'
let RNURL = global.URL
URL.createObjectURL = RNURL.createObjectURL
URL.revokeObjectURL = RNURL.revokeObjectURL
global.URL = URL
global.URLSearchParams = URLSearchParams