url-parameter-append
v1.0.5
Published
A simple method for adding, removing or updating parameters on a querystring
Readme
Url Parameter Append
A quick and easy utility method for adding, updating or removing querystring parameters.
Installation
npm install url-parameter-appendTests
Tests can be executed using the following:
npm testHow 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=testor
const url = urlParameterAppend('http://example.com/', {search: 'test'});
console.log(url);http://example.com/?search=testReplace parameter:
const url = urlParameterAppend('http://example.com/?search=test', 'search', 'other');
console.log(url);
http://example.com/?search=otheror
const url = urlParameterAppend('http://example.com/?search=test', {search: 'other'});
console.log(url);
http://example.com/?search=otherRemove 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.
