1.0.5 • Published 3 years ago

url-parameter-append v1.0.5

Weekly downloads
1,109
License
ISC
Repository
github
Last release
3 years ago

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.

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

6 years ago

0.1.0

6 years ago