-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an instance of URL like: new URL('http://facebook.com')
throws an exception.
#16434
Comments
new URL('http://facebook.com')
throws an exception.new URL('http://facebook.com')
throws an exception.
|
@phillbaker what @ipeychev meant is the URL definition: https://developer.mozilla.org/en-US/docs/Web/API/URL |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Reproduced with: Packages: (wanted => installed) |
Reproduced in:
|
Having the issue as well, so sad :(
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This can be worked around. Add this little piece of nastiness to your // see https://github.com/facebook/react-native/issues/14796
import { Buffer } from "buffer";
global.Buffer = Buffer;
// see https://github.com/facebook/react-native/issues/16434
import { URL, URLSearchParams } from "whatwg-url";
global.URL = URL;
global.URLSearchParams = URLSearchParams; |
This comment has been minimized.
This comment has been minimized.
Same here. This would be nice to use when parsing URLs for deep link routing. |
This comment has been minimized.
This comment has been minimized.
i have the same problem while using web3 in websocketProvider. new URL() write in web3 source code, i can't change it. Any solution? |
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
React-native seems to replace URL with this one, to support local blob urls: https://github.com/facebook/react-native/blob/master/Libraries/Blob/URL.js |
👋 You should check this out: https://github.com/charpeni/react-native-url-polyfill. |
Closing as a workaround is provided in #16434 (comment) |
React Native does have its own built-in polyfill for the URL Web API [1], but it's so minimal that it has some serious bugs, and a React Native maintainer has even recommended `react-native-url-polyfill` as an official workaround for one of those bugs [2]. Many thanks to charpeni for the changes [2] that allow RN v0.60 support! And for the changes from our own PR charpeni/whatwg-url#3, to avoid touching the Buffer global. This commit uses a release candidate version; there will likely be an official release soon. [1]: https://developer.mozilla.org/en-US/docs/Web/API/URL [2]: facebook/react-native#16434 (comment) [3]: charpeni/react-native-url-polyfill@d4e26ce#diff-375a2b7b7d929526f0dd58cd8bb8665b Fixes: zulip#4081
React Native does have its own built-in polyfill for the URL Web API [1], but it's so minimal that it has some serious bugs, and a React Native maintainer has even recommended `react-native-url-polyfill` as an official workaround for one of those bugs [2]. Many thanks to charpeni for the changes [2] that allow RN v0.60 support! And for the changes from our own PR charpeni/whatwg-url#3, to avoid touching the Buffer global. This commit uses a release candidate version; there will likely be an official release soon. [1]: https://developer.mozilla.org/en-US/docs/Web/API/URL [2]: facebook/react-native#16434 (comment) [3]: charpeni/react-native-url-polyfill@d4e26ce#diff-375a2b7b7d929526f0dd58cd8bb8665b Fixes: zulip#4081
React Native does have its own built-in polyfill for the URL Web API [1], but it's so minimal that it has some serious bugs, and a React Native maintainer has even recommended `react-native-url-polyfill` as an official workaround for one of those bugs [2]. Many thanks to charpeni for the changes [3] that allow RN v0.60 support! And for the changes from our own PR charpeni/whatwg-url#3, to avoid touching the Buffer global. This commit uses a release candidate version; there will likely be an official release soon. [1]: https://developer.mozilla.org/en-US/docs/Web/API/URL [2]: facebook/react-native#16434 (comment) [3]: charpeni/react-native-url-polyfill@d4e26ce#diff-375a2b7b7d929526f0dd58cd8bb8665b Fixes: zulip#4081
@hramos if a polyfill existing is reason enough to close this issue then I think the React Native team should deprecate the URL module and outsource it to the community as they have with others. This weird, multi-year, limbo state of the URL module is not good... |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.6.0
Yarn: 0.24.6
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 8.3 Build version 8E162
Android Studio: 2.3 AI-162.3934792
Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: ^0.48.4 => 0.48.4
Target Platform: iOS (10.3)
Steps to Reproduce
URL
in any .js file, like this:Expected Behavior
The URL to be the native URL, this one. It was working fine in React 15, but in React 16 it was replaced with something internal. We use URL to parse URLs and extract information about the hostname, port, etc. so we need this behaviour back.
Actual Behavior
An exception is thrown:
Creating BlobURL objects is not supported yet.
Reproducible Demo
https://snack.expo.io/SJUA5i7TZ
The text was updated successfully, but these errors were encountered: