WHATWG URL usage for URL resoltuon with React Native detection #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactors the code to use WHATWG except in environments it detects as React-Native. This detection looks for global hooks that React-Native injections and ensures that it's an environment without a DOM. As long as at least one of these standard hooks are present and there is no DOM detected, the environment is determined to be react-native and the url library is used instead.
If React-Native is not detected, it will use the default, native WHATWG URL API instead. This will prevent deprecation warnings and potential security issues.
A new configuration boolean option was added called
forceLegacyUrlResolve. If there is ever such an edge case that the React Native isn't detected (e.g., if future implementations remove the current global hooks or suddenly start working with a window/document object), developers can setforceLegacyUrlResolveas true, which will bypass auto-detection and force the use of the external url library.This PR should resolve concerns of breaking compatibility with react-native and allows the nodejs environment to work with the library that's is best suited for it.
Fixes #172