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
Maintainers
1
Weekly downloads
771
decreased by-30.79%

Weekly downloads

Readme

Source

Url Parameter Append

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');

or

import urlParameterAppend from '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.ts

Tests use the jest testing framework.

Keywords

FAQs

Last updated on 11 May 2021

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