Socket
Socket
Sign inDemoInstall

url-parameter-append

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    url-parameter-append

A simple method for adding, removing or updating parameters on a querystring


Version published
Weekly downloads
708
decreased by-31.06%
Maintainers
1
Install size
4.67 kB
Created
Weekly downloads
 

Readme

Source

Url Parameter Append

Build Status

A quick and easy utility method for adding, updating or removing querystring parameters.

Installation

npm install url-parameter-append

Tests

Tests can be executed using the following:

npm test

How to Use

Reference the package

const urlParameterAppend = require('url-parameter-append');

Add querystring

const url = urlParameterAppend('http://example.com/', 'search', 'test');
console.log(url);
http://example.com/?search=test

or

const url = urlParameterAppend('http://example.com/', {search: 'test'});
console.log(url);
http://example.com/?search=test

Replace parameter

const url = urlParameterAppend('http://example.com/?search=test', 'search', 'other');
console.log(url);

http://example.com/?search=other

or

const url = urlParameterAppend('http://example.com/?search=test', {search: 'other'});
console.log(url);

http://example.com/?search=other

Remove parameter

const url = urlParameterAppend('http://example.com/?search=test', 'search', null);
console.log(url);
http://example.com/

or

const url = urlParameterAppend('http://example.com/?search=test', {search: null});
console.log(url);
http://example.com/

More examples can be found in url-parameter-append.spec.js

Tests use the jest testing framework.

Keywords

FAQs

Last updated on 05 Jun 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc