Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenvachon/universal-url-lite
A smaller Universal WHATWG URL, for Browserify/etc.
https://github.com/stevenvachon/universal-url-lite
browserify nodejs url url-parsing urlsearchparams whatwg
Last synced: 2 months ago
JSON representation
A smaller Universal WHATWG URL, for Browserify/etc.
- Host: GitHub
- URL: https://github.com/stevenvachon/universal-url-lite
- Owner: stevenvachon
- License: mit
- Created: 2017-03-14T22:38:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-25T15:52:40.000Z (almost 4 years ago)
- Last Synced: 2024-10-03T18:46:08.150Z (3 months ago)
- Topics: browserify, nodejs, url, url-parsing, urlsearchparams, whatwg
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# universal-url-lite [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]
> A smaller Universal WHATWG [`URL`](https://developer.mozilla.org/en/docs/Web/API/URL), for Browserify/etc.
The [universal-url](https://npmjs.com/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.
## Installation
[Node.js](http://nodejs.org/) `>= 6` is required. To install, type this at the command line:
```shell
npm install universal-url-lite
```## Default Shim ![File Size][filesize-lite-uncp-image] ![File Size][filesize-lite-gzip-image]
Usage:
```json
"browser": {
"universal-url": "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:
```js
const url1 = new URL('http://ㅼㅼㅼ/');
const url2 = new URL('http://ᄯᄯᄯ/');console.log(url1.hostname === url2.hostname);
//-> false -- which is incorrect
```With invalid IDNAs passing through without error, you will instead need to rely on errors produced by `XMLHttpRequest`/`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.
```shell
browserify in.js --outfile=out.js --noparse='/project/node_modules/universal-url-lite/lite.js'
```## "Native" Shim ![File Size][filesize-natv-uncp-image]
This actually includes no shim at all for browser builds. Only the latest browsers will be supported.
Usage:
```json
"browser": {
"universal-url": "universal-url-lite/native"
}
```[npm-image]: https://img.shields.io/npm/v/universal-url-lite.svg
[npm-url]: https://npmjs.org/package/universal-url-lite
[filesize-lite-gzip-image]: https://img.shields.io/badge/size-19kB%20gzipped-blue.svg
[filesize-lite-uncp-image]: https://img.shields.io/badge/size-73kB-blue.svg
[filesize-natv-uncp-image]: https://img.shields.io/badge/size-336B-blue.svg
[travis-image]: https://img.shields.io/travis/stevenvachon/universal-url-lite.svg
[travis-url]: https://travis-ci.org/stevenvachon/universal-url-lite
[greenkeeper-image]: https://badges.greenkeeper.io/stevenvachon/universal-url-lite.svg
[greenkeeper-url]: https://greenkeeper.io/