Core Javascript Library for URL Operations.
One library to perform most of the URI operations. Such as,
| Action | Method | Description |
|---|---|---|
| Add | URI.add([{'page': 1}]) | To add new param to URL. |
| Bulk Add | URI.add([{'page': 1},{'index',2}]) | To add multiple params to URL. |
| Update | URI.add([{'page': 2}]) | To update param by simple add same param. |
| Delete | URI.remove('page') | To remove param from URL. |
| Bulk Delete | URI.remove(['page','index']) | To remove multiple param from URL. |
| Delete All | URI.removeAll() | To remove all param in the URL. |
| Clear | URI.clear() | TO clear the URL history. |
| Update | URI.update() | To update URI status. |
| Get | URI.get('page') | To get value of a param. |
Include the URI library to project by using,
<script src="uri_helper.js"></script>To get list of URI params as Object.
URI.getAll();
// URL : http://domain.com/?type=my-ticket&page=1&limit=5
// Output : ["type=myTicket", "page=1", "limit=5"]
To get value of the param from URI.
URI.get('type');
// URI : http://domain.com/?type=myTicket&page=2&limit=5
// OUT : 'myTicket'To add list of param to the URI. If item already exists, then value get updated.
URI.add([{'page': 1}, {'limit': 5}]);
// Before URL : http://domain.com/?type=my-ticket
// After URL : http://domain.com/?type=my-ticket&page=1&limit=5
To remove list of param from the URI.
URI.remove(['page','limit']); // For Bulk.
URI.remove('type'); // For Single.
// Before URL : http://domain.com/?type=my-ticket&page=1&limit=5
// After URL : http://domain.com/?To remove all param in the URI.
URI.removeAll();
// Before URI : http://domain.com/?type=my-ticket&page=2&limit=5
// After URI : http://domain.com/?To go back to previous page by update the URI.
URI.prevPage();
// Before URL : http://domain.com/?type=my-ticket&page=2&limit=5
// After URL : http://domain.com/?type=my-ticket&page=1&limit=5To move to next page by update the URI.
URI.nextPage();
// Before URL : http://domain.com/?type=my-ticket&page=1&limit=5
// After URL : http://domain.com/?type=my-ticket&page=2&limit=5
To check the param is exist in URI or Not.
URI.isParamExists('page');
URI.isParamExists('newPage');
// URL : http://domain.com/?type=my-ticket&page=2&limit=5
// OUT 1 : true
// OUT 2 : false
MIT License