Merge pull request #17661 from artursvonda/update-qs-to-2-5

[qs] Add new options introduced in qs 6.5
This commit is contained in:
Ron Buckton
2017-07-04 21:44:13 -07:00
committed by GitHub
2 changed files with 13 additions and 1 deletions
+4 -1
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;
+9
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');
}