Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

append-query

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

append-query

Append querystring params to a URL.

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

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

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 upgrade extend dependency to ^2.0.0
  • 2.0.1
    • fix typo
  • 2.0.0
    • fix #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)

Copyright 2014 Cameron Lakenen

Keywords

FAQs

Package last updated on 13 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc