Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 87597ca

Browse files
lucaskendaStarefossen
authored andcommitted
fix(parser): make sure toNumber and toBoolean can be turned off
* toBoolean and toNumber change. I tried to use: var qs = new MongoQS({ string: { toNumber: false } }); But toNumber and toBoolean is always in true. I propose a change so firstly it checks if it is boolean and then makes the change. Thanks for this great module! :) * Fix without ( and ) in typeof * Strings changed to singlequoted for test pass
1 parent 24efed5 commit 87597ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = function MongoQS(options) {
1212
// String Value Parsing
1313
opts.string = opts.string || {};
1414
this.string = opts.string || {};
15-
this.string.toBoolean = opts.string.toBoolean || true;
16-
this.string.toNumber = opts.string.toNumber || true;
15+
this.string.toBoolean = (typeof opts.string.toBoolean === 'boolean') ? opts.string.toBoolean : true;
16+
this.string.toNumber = (typeof opts.string.toNumber === 'boolean') ? opts.string.toNumber : true;
1717

1818
this.keyRegex = opts.keyRegex || /^[a-zæøå0-9-_.]+$/i;
1919
this.valRegex = opts.valRegex || /[^a-zæøå0-9-_.* ]/i;

0 commit comments

Comments
 (0)