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

query-string

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-string - npm Package Compare versions

Comparing version 6.7.0 to 6.8.0

36

index.d.ts

@@ -16,3 +16,3 @@ export interface ParseOptions {

queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -24,3 +24,3 @@

queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -32,3 +32,3 @@

queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -40,3 +40,3 @@

queryString.parse('foo=1&foo=2&foo=3');
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -75,12 +75,25 @@ */

@example
```js
queryString.parse('foo=1', {parseNumbers: true});
//=> {foo: 1}
```
queryString.parse('foo[]=1&foo[]=2&foo[]=3', {parseNumbers: true});
//=> foo: [1, 2, 3]
*/
readonly parseNumbers?: boolean;
/**
Parse the value as a boolean type instead of string type if it's a boolean.
@default false
@example
```
queryString.parse('foo=true', {parseBooleans: true});
//=> {foo: true}
```
*/
readonly parseNumbers?: boolean;
readonly parseBooleans?: boolean;
}
export interface ParsedQuery {
readonly [key: string]: string | number | Array<string | number> | null | undefined;
export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
}

@@ -95,2 +108,5 @@

*/
export function parse(query: string, options: {parseBooleans: true, parseNumbers: true} & ParseOptions): ParsedQuery<string | boolean | number>;
export function parse(query: string, options: {parseBooleans: true} & ParseOptions): ParsedQuery<string | boolean>;
export function parse(query: string, options: {parseNumbers: true} & ParseOptions): ParsedQuery<string | number>;
export function parse(query: string, options?: ParseOptions): ParsedQuery;

@@ -145,3 +161,3 @@

queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
//=> 'foo[0]=1&foo[1]=2&foo[3]=3'
//=> 'foo[0]=1&foo[1]=2&foo[2]=3'
```

@@ -148,0 +164,0 @@

@@ -179,3 +179,4 @@ 'use strict';

arrayFormat: 'none',
parseNumbers: false
parseNumbers: false,
parseBooleans: false
}, options);

@@ -209,2 +210,6 @@

if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
value = value.toLowerCase() === 'true';
}
formatter(decode(key, options), value, ret);

@@ -211,0 +216,0 @@ }

{
"name": "query-string",
"version": "6.7.0",
"version": "6.8.0",
"description": "Parse and stringify URL query strings",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -75,3 +75,3 @@ # query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](https://travis-ci.org/sindresorhus/query-string)

queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -83,3 +83,3 @@

queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -91,3 +91,3 @@

queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -99,3 +99,3 @@

queryString.parse('foo=1&foo=2&foo=3');
//=> foo: ['1', '2', '3']
//=> {foo: ['1', '2', '3']}
```

@@ -116,4 +116,4 @@

```js
queryString.parse('foo[]=1&foo[]=2&foo[]=3', {parseNumbers: true});
//=> foo: [1, 2, 3]
queryString.parse('foo=1', {parseNumbers: true});
//=> {foo: 1}
```

@@ -123,2 +123,14 @@

##### parseBooleans
Type: `boolean`<br>
Default: `false`
```js
queryString.parse('foo=true', {parseBooleans: true});
//=> {foo: true}
```
Parse the value as a boolean type instead of string type if it's a boolean.
### .stringify(object, [options])

@@ -162,3 +174,3 @@

queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
//=> 'foo[0]=1&foo[1]=2&foo[3]=3'
//=> 'foo[0]=1&foo[1]=2&foo[2]=3'
```

@@ -243,3 +255,3 @@

queryString.stringify({color: ['taupe', 'chartreuse'], id: '515'});
//=> 'color=chartreuse&color=taupe&id=515'
//=> 'color=taupe&color=chartreuse&id=515'
```

@@ -246,0 +258,0 @@

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