diff --git a/types/qs/index.d.ts b/types/qs/index.d.ts index d3574383a5..2ecbed14be 100644 --- a/types/qs/index.d.ts +++ b/types/qs/index.d.ts @@ -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 // Leon Yu // Belinda Teh // Melvin Lee +// Arturs Vonda // 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; diff --git a/types/qs/qs-tests.ts b/types/qs/qs-tests.ts index d71aa55957..49fe89a4aa 100644 --- a/types/qs/qs-tests.ts +++ b/types/qs/qs-tests.ts @@ -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'); +}