# append-query

> Append querystring params to a URL.

Latest version **2.1.1** (published 2021-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install append-query
pnpm add append-query
yarn add append-query
bun add append-query
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2021-05-13 |
| First published | 2014-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/append-query) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Cameron Lakenen |
| Maintainers | lakenen |
| Keywords | string, url, querystring, query params, query, append |

## Links

- npm: https://www.npmjs.com/package/append-query
- Repository: https://github.com/lakenen/node-append-query
- Issues: https://github.com/lakenen/node-append-query/issues
- npm.io page: https://npm.io/package/append-query

## Dependencies (1)

- [extend](https://npm.io/package/extend.md) ^3.0.2

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2021-05-13
- 2.1.0 — 2019-07-31
- 2.0.1 — 2016-10-24
- 2.0.0 — 2016-10-11
- 1.1.0 — 2015-01-05
- 1.0.0 — 2014-07-22

## README

[![Build Status](https://travis-ci.org/lakenen/node-append-query.png?branch=master)](https://travis-ci.org/lakenen/node-append-query)

# append-query

Append querystring params to a URL.

## Installation

```
npm install append-query
```


## Usage

`appendQuery(url, query[, options])`

* **url** - a string URL to append to.
* **query** - a string or object containing query params to append.
* **options** (optional)
  * **encodeComponents** - whether or not to encode appended passed params using `encodeURIComponent`. Default: true.
  * **removeNull** - whether or not to remove params for null properties in the query object. Default: false (properties will be preserved with no value).

Example
```js
var appendQuery = require('append-query')

appendQuery('http://example.com/foo', 'bar=baz&beep=boop')
// http://example.com/foo?bar=baz&beep=boop
appendQuery('http://example.com/?foo=bar', 'hello=world')
// http://example.com/?foo=bar&hello=world
appendQuery('http://example.com/', { beep: 'boop' })
// http://example.com/?beep=boop
appendQuery('http://example.com/', { nothing: null })
// http://example.com/?nothing

// using pre-encoded values
appendQuery('http://example.com/', { preEncoded: '%22hello%2C%20world!%22' }, { encodeComponents: false })
// http://example.com/?preEncoded=%22hello%2C%20world!%22

// remove existing values
appendQuery('http://example.com/?test=1', { test: null }, { removeNull: true })
// http://example.com/

```


## Running Tests

```
npm test
```


## Change Log


* **2.1.0**
  - [#9](https://github.com/lakenen/node-append-query/pull/9) upgrade extend dependency to `^2.0.0`
* **2.0.1**
  - fix typo
* **2.0.0**
  - fix [#5](https://github.com/lakenen/node-append-query/issues/5)
  - add options: `encodeComponents` and `removeNull`
* **1.1.0**
  - add support for recursive serialization of nested objects
  - add support for arrays as properties


## License

([The MIT License](LICENSE))

Copyright 2014 Cameron Lakenen

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