{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/16434","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/16434/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/16434/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/16434/events","html_url":"https://github.com/facebook/react-native/issues/16434","id":266197101,"number":16434,"title":"Creating an instance of URL like: `new URL('http://facebook.com')` throws an exception.","user":{"login":"ipeychev","id":78014,"avatar_url":"https://avatars3.githubusercontent.com/u/78014?v=4","gravatar_id":"","url":"https://api.github.com/users/ipeychev","html_url":"https://github.com/ipeychev","followers_url":"https://api.github.com/users/ipeychev/followers","following_url":"https://api.github.com/users/ipeychev/following{/other_user}","gists_url":"https://api.github.com/users/ipeychev/gists{/gist_id}","starred_url":"https://api.github.com/users/ipeychev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipeychev/subscriptions","organizations_url":"https://api.github.com/users/ipeychev/orgs","repos_url":"https://api.github.com/users/ipeychev/repos","events_url":"https://api.github.com/users/ipeychev/events{/privacy}","received_events_url":"https://api.github.com/users/ipeychev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-10-17T16:35:38Z","updated_at":"2018-05-25T18:48:04Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION.\r\n-->\r\n\r\n### Is this a bug report?\r\n\r\nYes\r\n\r\n### Have you read the [Contributing Guidelines](https://facebook.github.io/react-native/docs/contributing.html)?\r\n\r\nYes\r\n\r\n### Environment\r\n\r\n  Environment:\r\n  OS:  macOS Sierra 10.12.6\r\n  Node:  8.6.0\r\n  Yarn:  0.24.6\r\n  npm:  5.3.0\r\n  Watchman:  4.7.0\r\n  Xcode:  Xcode 8.3 Build version 8E162\r\n  Android Studio:  2.3 AI-162.3934792\r\n\r\nPackages: (wanted => installed)\r\n  react: 16.0.0-alpha.12 => 16.0.0-alpha.12\r\n  react-native: ^0.48.4 => 0.48.4\r\n  Target Platform: iOS (10.3)\r\n\r\n### Steps to Reproduce\r\n\r\n1. Create a ReactNative project, which uses React Native 16\r\n2. Try to create an instance of `URL` in any .js file, like this:\r\n    ```javascript\r\n    const url = new URL('http://facebook.com');\r\n    ```\r\n3. Run the project\r\n\r\n### Expected Behavior\r\n\r\nThe URL to be the native URL, [this one](https://developer.mozilla.org/en-US/docs/Web/API/URL). **It was working fine in React 15, but in React 16 it was replaced with something [internal](https://github.com/facebook/react-native/blob/91372e8f9aafcad2b5594175b1a3ce6f9c8f3b8e/Libraries/Blob/URL.js).** We use URL to parse URLs and extract information about the hostname, port, etc. so we need this behaviour back.\r\n\r\n### Actual Behavior\r\nAn exception is thrown: `Creating BlobURL objects is not supported yet.`\r\n\r\n<img width=\"376\" alt=\"screen shot 2017-10-17 at 18 15 19\" src=\"https://user-images.githubusercontent.com/78014/31676230-3e1d639c-b367-11e7-852b-23f528e7a2ef.png\">\r\n\r\n### Reproducible Demo\r\n\r\nhttps://snack.expo.io/SJUA5i7TZ"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/392147974","html_url":"https://github.com/facebook/react-native/issues/16434#issuecomment-392147974","issue_url":"https://api.github.com/repos/facebook/react-native/issues/16434","id":392147974,"user":{"login":"mike-marcacci","id":690517,"avatar_url":"https://avatars1.githubusercontent.com/u/690517?v=4","gravatar_id":"","url":"https://api.github.com/users/mike-marcacci","html_url":"https://github.com/mike-marcacci","followers_url":"https://api.github.com/users/mike-marcacci/followers","following_url":"https://api.github.com/users/mike-marcacci/following{/other_user}","gists_url":"https://api.github.com/users/mike-marcacci/gists{/gist_id}","starred_url":"https://api.github.com/users/mike-marcacci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mike-marcacci/subscriptions","organizations_url":"https://api.github.com/users/mike-marcacci/orgs","repos_url":"https://api.github.com/users/mike-marcacci/repos","events_url":"https://api.github.com/users/mike-marcacci/events{/privacy}","received_events_url":"https://api.github.com/users/mike-marcacci/received_events","type":"User","site_admin":false},"created_at":"2018-05-25T18:48:04Z","updated_at":"2018-05-25T18:48:04Z","author_association":"NONE","body":"This can be worked around. Add this little piece of nastiness to your `index.js`:\r\n\r\n```ts\r\n// see https://github.com/facebook/react-native/issues/14796\r\nimport { Buffer } from \"buffer\";\r\nglobal.Buffer = Buffer;\r\n\r\n// see https://github.com/facebook/react-native/issues/16434\r\nimport { URL, URLSearchParams } from \"whatwg-url\";\r\nglobal.URL = URL;\r\nglobal.URLSearchParams = URLSearchParams;\r\n```"}}
{"actor":{"display_login":"mike-marcacci"}}