npm

Need private packages and team management tools?Check out npm Orgs. »

queryfy

1.1.1 • Public • Published

queryfy

Build Status

Install

bower install queryfy
<script src="bower_components/queryfy/index.js"></script>

or npm

npm install -S queryfy

Usage

Standard

const q = require('queryfy');
 
const params = {
  param1: 'This is param1',
  param2: 'This is param2'
};
 
const path = 'https://something.com/';
 
console.log(q.queryfy(path, params));
// https://something.com/?param1=This%20is%20param1&param2=This%20is%20param2

or you can specify only the first argument with the query object

const params = {
  param1: 'This is param1',
  param2: 'This is param2'
};
console.log(q.queryfy(params));
// param1=This%20is%20param1&param2=This%20is%20param2

Reversed

const q = require('queryfy');
 
const path = 'https://something.com/?param1=This%20is%20param1&param2=This%20is%20param2';
 
console.log(q.deQueryfy(path));
// { param1: 'This is param1', param2: 'This is param2' }

it also supports only the query string with or without ?

console.log(q.deQueryfy('param1=This%20is%20param1&param2=This%20is%20param2'));
// { param1: 'This is param1', param2: 'This is param2' }
 
console.log(q.deQueryfy('?param1=This%20is%20param1&param2=This%20is%20param2'));
// { param1: 'This is param1', param2: 'This is param2' }

install

npm i queryfy

Downloadsweekly downloads

1

version

1.1.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability