Gathering detailed insights and metrics for react-native-url-polyfill
Gathering detailed insights and metrics for react-native-url-polyfill
Gathering detailed insights and metrics for react-native-url-polyfill
Gathering detailed insights and metrics for react-native-url-polyfill
cross-fetch
Universal WHATWG Fetch API for Node, Browsers and React Native
react-native-get-random-values
A small implementation of `crypto.getRandomValues` for React Native. This is useful to polyfill for libraries like [uuid](https://www.npmjs.com/package/uuid) that depend on it.
react-native-polyfill-globals
Polyfills and patches missing or partially supported web and core APIs
react-native-reanimated
More powerful alternative to Animated library for React Native.
🔗A lightweight and trustworthy URL polyfill for React Native.
npm install react-native-url-polyfill
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
346 Stars
324 Commits
17 Forks
3 Watching
4 Branches
7 Contributors
Updated on 31 Oct 2024
Minified
Minified + Gzipped
Java (36.86%)
JavaScript (26.24%)
Ruby (10.08%)
Objective-C (8.17%)
Objective-C++ (7.68%)
C++ (7.2%)
Makefile (1.58%)
Starlark (1.25%)
TypeScript (0.9%)
Shell (0.06%)
Cumulative downloads
Total Downloads
Last day
-5.5%
147,054
Compared to previous day
Last week
1.2%
737,032
Compared to previous week
Last month
10.8%
3,076,484
Compared to previous month
Last year
84.5%
30,771,082
Compared to previous year
A lightweight and trustworthy URL polyfill for React Native
react-native-url-polyfill is an implementation of the WHATWG URL Standard optimized for React Native.
whatwg-url
(whatwg-url-without-unicode
) where unicode support has been stripped out — Going down from 372 KB to 40.9 KB.react-native-url-polyfill/auto
will be no-op on web.React Native does include a polyfill for URL
, but this polyfill is homemade — in order to keep it light-weight — and was initially created to handle specific use cases.
Meanwhile, React Native has grown around that polyfill, then some unexpected errors have arisen.
Known issues (non-exhaustive) with React Native's URL are:
- URL cannot handle "localhost" domain for base url react-native#26019.
- URL implementation should add a trailing slash to the base react-native#25717.
- URL incorrectly adds trailing slash react-native#24428.
- Creating an instance of URL like:
new URL('http://facebook.com')
throws an exception react-native#16434.
That's why you may need this external dependency. So, if you use URL
within your app, you probably want to take a look at the installation steps below!
Unfortunately, adding react-native-url-polyfill
to React Native source code would mean adding 📦 73.67 KB (as of RN 0.72) to the JavaScript bundle, that's why it's not included by default.
First, you need to install the polyfill, which can be done with Yarn or npm.
1yarn add react-native-url-polyfill
1npm install --save react-native-url-polyfill
Then, the polyfill can be used in multiple ways. Pick your preferred option.
ℹ️ To verify if the polyfill has been correctly applied, you can check if the global variable
REACT_NATIVE_URL_POLYFILL
contains the current package and version like:react-native-url-polyfill@CURRENT_VERSION
.
Locate your JavaScript entry-point file, commonly called index.js
at the root of your React Native project.
Then, import react-native-url-polyfill/auto
at the top of your entry-point file, the polyfill will be automatically applied.
1import 'react-native-url-polyfill/auto';
If you want to apply the polyfill when you're ready, you can import setupURLPolyfill
and call it yourself.
⚠️ Metro doesn't support optional imports.
If you do not apply the polyfill, it will still be added to your JavaScript bundle. Even if it's wrapped in a condition, Metro won't strip it in production.
1import { setupURLPolyfill } from 'react-native-url-polyfill'; 2 3setupURLPolyfill();
If you prefer not to apply this polyfill over React Native's default URL
, you can still import those classes manually when you want them.
1import { URL, URLSearchParams } from 'react-native-url-polyfill'; 2 3const url = new URL('https://github.com'); 4const searchParams = new URLSearchParams('q=GitHub');
react-native-url-polyfill is MIT licensed.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
94 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More