# @flayyer/better-url

> Wrapper of `URL` class with additional formatting features.

Latest version **1.0.1** (published 2021-06-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @flayyer/better-url
pnpm add @flayyer/better-url
yarn add @flayyer/better-url
bun add @flayyer/better-url
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-06-18 |
| First published | 2021-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Patricio López Juri |
| Maintainers | lopezjurip |

## Links

- npm: https://www.npmjs.com/package/@flayyer/better-url
- npm.io page: https://npm.io/package/@flayyer/better-url

## Recent versions

- 1.0.1 (latest) — 2021-06-18
- 1.0.0 — 2021-06-18
- 0.3.5 — 2021-05-20
- 0.3.4 — 2021-05-20
- 0.3.3 — 2021-04-16
- 0.3.2 — 2021-04-16
- 0.3.1 — 2021-03-18
- 0.3.0 — 2021-03-16
- 0.2.1 — 2021-03-16
- 0.2.0 — 2021-03-16

## README

# @flayyer/better-url

> This is not efficient but is practical for our needs.

Wrapper of `URL` class with additional formatting features but it is not a drop-in replacement because it has non-standard construction.

**Implements the `URL` class definition but preserves `base`'s path and optionally queryparams when resolving URLs.**

```sh
yarn add @flayyer/better-url
```

We recommend using it in conjunction with https://github.com/sindresorhus/normalize-url

## Usage

```ts
import { BetterURL } from "@flayyer/better-url";

const url = new BetterURL("/subpath?q=bye&title=title", "https://example.com/path?q=hello&desc=desc", undefined, { keepBaseSearch: true });
console.log(url.format({ protocol: true, hostname: true, pathname: true, search: true }));
// https://example.com/path/subpath?q=bye&title=title&desc=desc

/** Compared to native URL class: */
const url = new URL("/subpath?q=bye&title=title", "https://example.com/path?q=hello&desc=desc");
console.log(url.href);
// 'https://example.com/subpath?q=bye&title=title
```

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