A smaller Universal WHATWG
URL, for Browserify/etc.
The universal-url package bundles to 392kB (99kB gzipped). This package exists to compile the same to a smaller file size via custom optimizations.
This package is not meant to be required/imported directly. It should be added to your browser build process as an alias.
>= 6 is required. To install, type this at the command line:
npm install universal-url-lite
File size optimizations have been made, particularly the near-complete exclusion of the TR46 implementation. Functionality is essentially the same as the
universal-url package, with the exception of IDNA validation and normalization. If a URL contains a hostname with any of the ~4500 Unicode characters requiring a specific casefold, comparison will produce false negatives. Consider this example:
const url1 = '';const url2 = '';if url1hostname !== url2hostname// This is wrong
With invalid IDNAs passing through without error, you will instead need to rely on errors produced by
fetch to know that such URLs are unreachable.
Note: You will need to exclude this browser shim from bundle parsing since it has already been compiled. Browserify has the
--noparse CLI option and Webpack has the
noParse package.json key.
browserify in.js --outfile=out.js --noparse='/project/node_modules/universal-url-lite/lite.js'
This actually includes no shim at all for browser builds. Only the latest browsers will be supported.