We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 81f1a15 commit 0c9cc6bCopy full SHA for 0c9cc6b
index.js
@@ -0,0 +1,24 @@
1
+function parseConnectionParams(paramstring, parseValues = false) {
2
+ if (parseValues) {
3
+ const params = {};
4
+ const numberRegex = /^[-+]?(\d+\.)?\d+(E[-+]?\d+)?$/i;
5
+
6
+ paramstring.split('&').map(s => {
7
+ let [key, val] = s.split('=');
8
+ const lowerCasedValue = val.toLowerCase();
9
+ if (lowerCasedValue === 'true') val = true;
10
+ else if (lowerCasedValue === 'false') val = false;
11
+ else if (numberRegex.test(val)) val = parseFloat(val);
12
13
+ params[key] = val;
14
+ });
15
16
+ return params;
17
+ } else {
18
+ return paramstring;
19
+ }
20
+}
21
22
+module.exports = {
23
+ parseConnectionParams
24
+};
0 commit comments