JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 653
  • Score
    100M100P100Q91674F
  • License MIT

a simple tool that allows you to remove any querystring from the url

Package Exports

  • qsm

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (qsm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Query String Manager

A simple tool that allows you to add and remove any querystring from the url

Install

npm install --save qsm

Usage

qsm.add(string, array) array is an array of objects with {query: 'query', value: 'value'}

qsm.remove(string, string)

qsm.clear(string);

qsm.replace(string, string)


Add

Appends querystring to the url.

var qsm = require('qsm');
var newurl = qsm.add('http://mywebsite.com', [{ query: 'userId', value: 1337 }]);

// newurl outputs: http://mywebsite.com?userId=1337

Remove

Removes any querystring by key

var qsm = require('qsm');
var newurl = qsm.remove('http://mywebsite.com?userId=1337&sort=type', 'userId');

// newurl outputs: http://mywebsite.com?sort=type

Clear

Clears all querystrings from the url

var qsm = require('qsm');
var newurl = qsm.clear('http://mywebsite.com?userId=1337&sort=type');

// newurl outputs: http://mywebsite.com

Replace

Replaces current querystrings with new ones.

var qsm = require('qsm');
var newurl = qsm.replace('http://mywebsite.com?userId=1337&sort=type', [{ query: 'hasObject', value: true }]);

// newurl outputs: http://mywebsite.com?hasObject=true

Exist

Checks if the current url has the querystring. returns boolean

var qsm = require('qsm');
var exists = qsm.exist('http://mywebsite.com?userId=1337&sort=type', 'userId');

// exists returns true

Get

Gets the value by key from the url returns either string or null

var qsm = require('qsm');
var exists = qsm.get('http://mywebsite.com?userId=1336,1337,1338&sort=type', 'userId');

// exists returns: 1336,1337,1338
// or if it doesnt exist: null