Skip to content

Conversation

@Alpha4615
Copy link
Contributor

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 set forceLegacyUrlResolve as 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

// Check for React Native specific global objects
const hasNativeBridgeHook =
typeof global !== 'undefined' &&
(typeof (global as any).nativeCallSyncHook === 'function' ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks outdated and might not be true under the new arch.

@ospfranco
Copy link
Collaborator

Sorry buddy, I'm not going to merge this until I absolutely have to. Not worth my time ask for more work when something is not broken.

@ospfranco ospfranco closed this Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NodeJS 24 DeprecationWarning: url.parse()

2 participants