Add new options introduced in qs 2.5

This commit is contained in:
Arturs Vonda
2017-06-30 20:32:01 +03:00
parent 862cccebb3
commit 0de24ae1b4
2 changed files with 13 additions and 1 deletions

5
types/qs/index.d.ts vendored
View File

@@ -1,9 +1,10 @@
// Type definitions for qs 6.4.0
// Type definitions for qs 6.5.0
// Project: https://github.com/ljharb/qs
// Definitions by: Roman Korneev <https://github.com/RWander>
// Leon Yu <https://github.com/leonyu>
// Belinda Teh <https://github.com/tehbelinda>
// Melvin Lee <https://github.com/zyml>
// Arturs Vonda <https://github.com/artursvonda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = QueryString;
@@ -23,6 +24,7 @@ declare namespace QueryString {
serializeDate?: (d: Date) => string;
format?: 'RFC1738' | 'RFC3986';
encodeValuesOnly?: boolean;
addQueryPrefix?: boolean;
}
interface IParseOptions {
@@ -36,6 +38,7 @@ declare namespace QueryString {
allowPrototypes?: boolean;
parameterLimit?: number;
strictNullHandling?: boolean;
ignoreQueryPrefix?: boolean;
}
function stringify(obj: any, options?: IStringifyOptions): string;

View File

@@ -233,6 +233,11 @@ qs.parse('a=b&c=d', { delimiter: '&' });
assert.deepEqual(parsedStrictNull, { a: null, b: '' });
}
() => {
var parsedQueryPrefix = qs.parse('?a&b=', { ignoreQueryPrefix: true });
assert.deepEqual(parsedQueryPrefix, { a: '', b: '' });
}
() => {
var nullsSkipped = qs.stringify({ a: 'b', c: null }, { skipNulls: true });
assert.equal(nullsSkipped, 'a=b');
@@ -278,3 +283,7 @@ qs.parse('a=b&c=d', { delimiter: '&' });
);
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
}
() => {
assert.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b');
}