# iso-url

> Isomorphic/Universal WHATWG URL API with some support legacy node URL API

Latest version **1.2.1** (published 2021-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install iso-url
pnpm add iso-url
yarn add iso-url
bun add iso-url
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2021-10-20 |
| First published | 2018-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Hugo Dias |
| Maintainers | hugomrdias |
| Keywords | url, node, browser |

## Links

- npm: https://www.npmjs.com/package/iso-url
- Repository: https://github.com/hugomrdias/iso-url
- Homepage: https://github.com/hugomrdias/iso-url#readme
- Issues: https://github.com/hugomrdias/iso-url/issues
- npm.io page: https://npm.io/package/iso-url

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.2.1 (latest) — 2021-10-20
- 1.1.5 — 2021-03-14
- 1.1.4 — 2021-03-04
- 1.1.3 — 2021-03-03
- 1.1.2 — 2021-03-01
- 1.1.1 — 2021-03-01
- 1.1.0 — 2021-03-01
- 1.0.0 — 2020-10-21
- 0.4.7 — 2020-03-10
- 0.4.6 — 2019-01-23
- 0.4.5 — 2019-01-23
- 0.4.4 — 2018-12-15
- 0.4.3 — 2018-12-15
- 0.4.2 — 2018-12-15
- 0.4.1 — 2018-12-15
- … 7 more at https://npm.io/package/iso-url/versions

## README

# iso-url [![NPM Version](https://img.shields.io/npm/v/iso-url.svg)](https://www.npmjs.com/package/iso-url) [![NPM Downloads](https://img.shields.io/npm/dt/iso-url.svg)](https://www.npmjs.com/package/iso-url) [![NPM License](https://img.shields.io/npm/l/iso-url.svg)](https://www.npmjs.com/package/iso-url) ![tests](https://github.com/hugomrdias/iso-url/workflows/tests/badge.svg) [![codecov](https://codecov.io/gh/hugomrdias/iso-url/badge.svg?branch=master)](https://codecov.io/gh/hugomrdias/iso-url?branch=master)

> Isomorphic/Univeral WHATWG URL API with some support legacy node URL API

This package is a universal wrapper for node `url` and browser window.URL with support for legacy `url.parse` properties in the URL instance and defaults for base to support relative urls like `url.parse`. Node URL [docs](https://nodejs.org/docs/latest-v10.x/api/url.html#url_the_whatwg_url_api).

## Caveats

No support for querystring objects. Use `URLSearchParams`.

## Install

```
$ npm install iso-url
```

## Usage

```js
const { URL, URLSearchParams, format, relative } = require('iso-url');

const url = new isoUrl('http://localhost/unicorns');
const newSearchParams = new URLSearchParams(url.searchParams);
```

## API

### new URL(url, [base])

#### input

Type: `string`

The absolute or relative input URL to parse. If input is relative, then base is required. If input is absolute, the base is ignored.

#### base

Type: `string|URL`  
Default: `https://localhost` in node and `self.location.protocol + '//' + self.location.host` in the browser.

The base URL to resolve against if the input is not absolute.

### format(url, [options])

Same as https://nodejs.org/api/url.html#url_url_format_url_options

### relative(url, [location], [protocalMap], [defaultProtocol])

Same as https://github.com/dominictarr/relative-url but doesn't support this syntax `'//:9999'`

## License

MIT © [Hugo Dias](http://hugodias.me)

---
_Source: https://npm.io/package/iso-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
