New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-querystring-stringify

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-querystring-stringify - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

11

index.js

@@ -6,5 +6,14 @@ 'use strict'

stringify.normalize = normalize
stringify.appendToUrl = appendToUrl
stringify.stringify = stringify
module.exports = stringify
function appendToUrl(url, i) {
const qs = stringify(i)
if (qs === '') return url
return url + '?' + qs
}
function stringify(i) {

@@ -36,3 +45,3 @@ if (i === null || typeof i !== 'object' || Array.isArray(i)) {

return Object.keys(i)
.map(key => {
.map((key) => {
return serialize(

@@ -39,0 +48,0 @@ i[key],

2

package.json
{
"name": "http-querystring-stringify",
"description": "Create querystrings",
"version": "2.0.0",
"version": "2.1.0",
"repository": "srcagency/http-querystring-stringify",

@@ -6,0 +6,0 @@ "scripts": {

@@ -18,3 +18,3 @@ # http-querystring-stringify

```js
var stringify = require('http-querystring-stringify')
const {stringify, appendToUrl} = require('http-querystring-stringify')

@@ -36,2 +36,12 @@ stringify({

// -> sites[0][name]=facebook&sites[0][color]=blue
appendToUrl('https://google.com', {
first: 'John',
last: 'Wayne',
})
// -> https://google.com?first=John&last=Wayne
appendToUrl('https://google.com', {
key: undefined,
})
// -> https://google.com
```

@@ -57,13 +67,13 @@

```js
var input = {
const input = {
a: '',
b: 's',
c: [ '1', '2', '3' ],
c: ['1', '2', '3'],
d: '&=[]',
e: [ '1', '2', [ '3', '4' ] ],
f: [ '1', { a: '1' } ],
e: ['1', '2', ['3', '4']],
f: ['1', {a: '1'}],
}
deepEqual(parse(stringify(input)), input);
-> true;
// deepEqual(parse(stringify(input)), input)
// -> true
```

@@ -77,25 +87,27 @@

```js
parse(stringify({
a: '',
b: 's',
c: [ '1', '2', '3' ],
d: '&=[]',
e: [ '1', '2', [ '3', '4' ] ],
f: [ '1', { a: '1' } ],
}));
-> {
parse(
stringify({
a: '',
b: 's',
c: ['1', '2', '3'],
d: '&=[]',
e: ['1', '2', ['3', '4']],
f: ['1', {a: '1'}],
})
)
// -> {
// a: '',
// b: 's',
// d: '&=[]',
// expect arrays to be collapsed like this
'c[]': [ '1', '2', '3' ],
// // expect arrays to be collapsed like this
// 'c[]': [ '1', '2', '3' ],
// expect objects and multi-level arrays to be flattened like this
'e[0]': '1',
'e[1]': '2',
'e[2][]': [ '3', '4' ],
'f[0]': '1',
'f[1][a]': '1',
};
// // expect objects and multi-level arrays to be flattened like this
// 'e[0]': '1',
// 'e[1]': '2',
// 'e[2][]': [ '3', '4' ],
// 'f[0]': '1',
// 'f[1][a]': '1',
// }
```

@@ -12,3 +12,13 @@ 'use strict'

test('normalize', t => {
test('exported values', (t) => {
t.equal(typeof stringify, 'function')
t.equal(typeof stringify.shake, 'function')
t.equal(typeof stringify.normalize, 'function')
t.equal(typeof stringify.appendToUrl, 'function')
t.equal(typeof stringify.stringify, 'function')
t.ok(stringify.stringify === stringify)
t.end()
})
test('normalize', (t) => {
t.deepEqual(

@@ -62,3 +72,3 @@ stringify.normalize([

test('shake', t => {
test('shake', (t) => {
t.deepEqual(

@@ -88,3 +98,3 @@ stringify.shake([

test('serialize', t => {
test('serialize', (t) => {
t.equal(

@@ -107,3 +117,3 @@ stringify.serialize({

test('stringify', t => {
test('stringify', (t) => {
t.throws(() => stringify(), /Only objects can be stringified/)

@@ -152,3 +162,3 @@ t.throws(() => stringify(null), /Only objects can be stringified/)

test('serialize (from petkaantonov/querystringparser)', t => {
test('serialize (from petkaantonov/querystringparser)', (t) => {
/*

@@ -471,3 +481,3 @@

test('compatibility with parsers', t => {
test('compatibility with parsers', (t) => {
const subject = {

@@ -498,3 +508,3 @@ a: '',

t.test('Node.js built-in (flat)', t => {
t.test('Node.js built-in (flat)', (t) => {
t.plan(1)

@@ -505,3 +515,3 @@

t.test('querystringparser', t => {
t.test('querystringparser', (t) => {
t.plan(1)

@@ -512,3 +522,3 @@

t.test('qs', t => {
t.test('qs', (t) => {
t.plan(1)

@@ -519,3 +529,3 @@

t.test('urijs (flat)', t => {
t.test('urijs (flat)', (t) => {
t.plan(1)

@@ -526,1 +536,25 @@

})
test('appendToUrl', (t) => {
t.equal(
stringify.appendToUrl('https://google.com', {
first: 'John',
last: 'Wayne',
}),
'https://google.com?first=John&last=Wayne'
)
t.equal(
stringify.appendToUrl('https://google.com', {
key: undefined,
}),
'https://google.com'
)
t.equal(
stringify.appendToUrl('https://google.com', {}),
'https://google.com'
)
t.end()
})
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