# @googlicius/build-url

> Build url helper

Latest version **1.0.11** (published 2021-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @googlicius/build-url
pnpm add @googlicius/build-url
yarn add @googlicius/build-url
bun add @googlicius/build-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.0.11 |
| Published | 2021-08-03 |
| First published | 2021-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | googlicius |
| Maintainers | haidang009 |

## Links

- npm: https://www.npmjs.com/package/@googlicius/build-url
- Repository: https://github.com/googlicius/build-url
- npm.io page: https://npm.io/package/@googlicius/build-url

## Recent versions

- 1.0.11 (latest) — 2021-08-03
- 1.0.8 — 2021-07-25
- 1.0.7 — 2021-07-23
- 1.0.3 — 2021-07-23
- 1.0.2 — 2021-07-22
- 1.0.1 — 2021-07-22
- 1.0.0 — 2021-07-22

## README

# Build URL

A helper to build url with query params as easy way. Helpful when your application routing or state management based on URL query params.

## Installation

```
npm install @googlicius/build-url
```

Or Yarn:

```
yarn add @googlicius/buil-url
```

## Usage

```javascript
import buildUrl from '@googlicius/build-url';

buildUrl('http://my-website.com/post', {
  queryParams: {
    page: 2,
  },
});

// Output: http://my-website.com/post?page=2
```

Add another query param

```javascript
buildUrl('http://my-website.com/post?page=2', {
  queryParams: {
    sort: 'title:asc',
  },
});

// Output: http://my-website.com/post?page=2&sort=title%3Aasc
```

Input url/path is omitted

```javascript
buildUrl({
  queryParams: {
    sort: 'title:asc',
  },
});

// Output: /?sort=title%3Aasc
```

Remove a query param

```javascript
buildUrl('images?page=2&sort=title:asc', {
  queryParams: {
    page: null,
  },
});

// Output: /images?sort=title%3Aasc
```

Always returns absolute url

```javascript
// Assume that current url is: http://awesome-website.com

buildUrl('/posts', {
  returnAbsoluteUrl: true,
  queryParams: {
    page: 2,
  },
});

// Output: http://awesome-website.com/posts?page=2
```

## License
MIT

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