url-parameter-append
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (17)

    Package Sidebar

    Install

    npm i url-parameter-append

    Weekly Downloads

    805

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    16 kB

    Total Files

    13

    Last publish

    Collaborators

    • allenevans