Skip to content

Commit

Permalink
[Refactor] parse/stringify: move allowDots config logic to its ow…
Browse files Browse the repository at this point in the history
…n variable
  • Loading branch information
ljharb committed Feb 28, 2024
1 parent 5f0449f commit 82a098e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/parse.js
Expand Up @@ -229,8 +229,10 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
throw new TypeError('The duplicates option must be either combine, first, or last');
}

var allowDots = typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots;

return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowDots: allowDots,
allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
Expand Down
4 changes: 3 additions & 1 deletion lib/stringify.js
Expand Up @@ -238,9 +238,11 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
}

var allowDots = typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots;

return {
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowDots: allowDots,
allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
arrayFormat: arrayFormat,
charset: charset,
Expand Down

0 comments on commit 82a098e

Please sign in to comment.