@letscooee/url-builder
v0.0.5
Published
Utility class to provide some utility for dealing with URLs
Downloads
146
Readme
URL Builder
A simple wrapper for TypeScript to build & parse a URL.
Installation
npm i @letscooee/url-builder
Usage
import {URLBuilder} from '@letscooee/url-builder';
const urlBuilder = new URLBuilder('https://example.com/try?foo=bar&age=20');
urlBuilder.setQueryParam('foo', 'bar-new');
urlBuilder.appendQueryParam('name', 'Jon');
console.log(urlBuilder.toString() === 'https://example.com/try?foo=bar-new&age=20&name=Jon');
console.log(urlBuilder.getQueryParam('foo') === 'bar-new');
urlBuilder.setPath('/save');
urlBuilder.setQueryString('name=Jon&country=India');
console.log(urlBuilder.toString() === 'https://example.com/save?name=Jon&country=India');
urlBuilder.clearQueryParams();
console.log(urlBuilder.toString() === 'https://example.com/save');
Release
npm publish --access public