Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qs-kit

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qs-kit - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

78

lib/qs.js

@@ -33,5 +33,8 @@ /*

This modification allow object notation and right-side array notation:
a.b=1&a.c=2 -> { a: { b: '1' , c: '2' } }
a=[b,c,d] -> { a: [ 'b' , 'c' , 'd' ] }
a.b=1&a.c=2 -> { a: { b: '1' , c: '2' } }
a[0]=one&a[1]=two -> { a: [ 'one' , 'two' ] }
If option 'rightHandSideBrackets' is on:
a=[b,c,d] -> { a: [ 'b' , 'c' , 'd' ] }
Still, not everything is possible.

@@ -61,7 +64,9 @@ */

*/
QueryString.parse = QueryString.decode = function( str , sep , eq , options )
QueryString.parse = QueryString.decode = function( str , options )
{
sep = sep || '&' ;
eq = eq || '=' ;
if ( ! options ) { options = {} ; }
var sep = options.separator || '&' ;
var eq = options.equal || '=' ;
var i , iMax , j , jMax , count = 0 , obj = {} ;

@@ -75,3 +80,3 @@

var maxItems = 1000 ;
if ( options && typeof options.maxItems === 'number' ) { maxItems = options.maxItems ; }
if ( typeof options.maxItems === 'number' ) { maxItems = options.maxItems ; }

@@ -82,3 +87,3 @@ iMax = str.length;

if ( options && typeof options.decodeURIComponent === 'function' )
if ( typeof options.decodeURIComponent === 'function' )
{

@@ -100,3 +105,3 @@ decode = options.decodeURIComponent;

if ( v[ 0 ] === '[' && v[ v.length - 1 ] === ']' )
if ( options.rightHandSideBrackets && v[ 0 ] === '[' && v[ v.length - 1 ] === ']' )
{

@@ -132,11 +137,13 @@ if ( v.length === 2 )

QueryString.stringify = QueryString.encode = function( obj , sep , eq , options )
QueryString.stringify = QueryString.encode = function( obj , options )
{
sep = sep || '&' ;
eq = eq || '=' ;
if ( ! options ) { options = {} ; }
var sep = options.separator || '&' ;
var eq = options.equal || '=' ;
obj = tree.extend( { flat: true , deepFilter: { blacklist: [ Array.prototype ] } } , {} , obj ) ;
var encode = QueryString.escape ;
if ( options && typeof options.encodeURIComponent === 'function' ) { encode = options.encodeURIComponent ; }
if ( typeof options.encodeURIComponent === 'function' ) { encode = options.encodeURIComponent ; }

@@ -155,25 +162,42 @@ if ( obj !== null && typeof obj === 'object' )

var v = obj[ k ] ;
var ks = encode( stringifyPrimitive( k ) ) + eq ;
var ks = encode( stringifyPrimitive( k ) ) ;
if ( Array.isArray( v ) )
{
var vlen = v.length ;
var vlast = vlen - 1 ;
var j ;
fields += ks + '[' ;
for ( j = 0 ; j < vlen ; j ++ )
if ( options.rightHandSideBrackets )
{
fields += encode( stringifyPrimitive( v[ j ] ) ) ;
if ( j < vlast ) { fields += ',' ; }
var vlen = v.length ;
var vlast = vlen - 1 ;
var j ;
fields += ks + eq + '[' ;
for ( j = 0 ; j < vlen ; j ++ )
{
fields += encode( stringifyPrimitive( v[ j ] ) ) ;
if ( j < vlast ) { fields += ',' ; }
}
fields += ']' ;
if ( vlen && i < flast ) { fields += sep ; }
}
fields += ']' ;
if ( vlen && i < flast ) { fields += sep ; }
else
{
var vlen = v.length ;
var vlast = vlen - 1 ;
var j ;
for ( j = 0 ; j < vlen ; j ++ )
{
fields += ks + '[' + j + ']' + eq + encode( stringifyPrimitive( v[ j ] ) ) ;
if ( j < vlast ) { fields += '&' ; }
}
if ( vlen && i < flast ) { fields += sep ; }
}
}
else
{
fields += ks + encode( stringifyPrimitive( v ) ) ;
fields += ks + eq + encode( stringifyPrimitive( v ) ) ;
if ( i < flast ) { fields += sep ; }

@@ -180,0 +204,0 @@ }

{
"name": "qs-kit",
"version": "0.1.3",
"version": "0.2.0",
"description": "A query string manipulation toolbox.",

@@ -10,3 +10,3 @@ "main": "lib/qs.js",

"dependencies": {
"tree-kit": "^0.5.5"
"tree-kit": "^0.5.6"
},

@@ -13,0 +13,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc