Repository: sindresorhus/query-string (js)

Issue:
TypeError when both parseBooleans and parseNumbers are enabled
Repro:
```js
const queryString = require('query-string');

queryString.parse(
  'num=1.23&bool=false', { parseNumbers: true, parseBooleans: true }
);
```
Results in error
```
/home/user/project/node_modules/query-string/index.js:209
                if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
                                                                      ^

TypeError: value.toLowerCase is not a function
```

Using query-string 6.8.0 and node 10.16.0

Pull request:
Fix using the `parseNumbers` and `parseBooleans` options together
Not tested but I expect it to work. Problem was that if it's was a number, value was set to number already and it still checked if it's a boolean.

Fixes #186

Patch:
diff --git a/index.js b/index.js
index 552baa4..da459c9 100644
--- a/index.js
+++ b/index.js
@@ -204,9 +204,7 @@ function parse(input, options) {
 
 		if (options.parseNumbers && !Number.isNaN(Number(value))) {
 			value = Number(value);
-		}
-
-		if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
+		} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
 			value = value.toLowerCase() === 'true';
 		}
 


Test patch:
diff --git a/test/parse.js b/test/parse.js
index 61bba90..9ae2dc6 100644
--- a/test/parse.js
+++ b/test/parse.js
@@ -253,3 +253,8 @@ test('boolean value returns as boolean if option is set', t => {
 	t.deepEqual(queryString.parse('foo=true', {parseBooleans: true}), {foo: true});
 	t.deepEqual(queryString.parse('foo=false&bar=true', {parseBooleans: true}), {foo: false, bar: true});
 });
+
+test('boolean value returns as boolean and number value as number if both options are set', t => {
+	t.deepEqual(queryString.parse('foo=true&bar=1.12', {parseNumbers: true, parseBooleans: true}), {foo: true, bar: 1.12});
+	t.deepEqual(queryString.parse('foo=16.32&bar=false', {parseNumbers: true, parseBooleans: true}), {foo: 16.32, bar: false});
+});