summaryrefslogtreecommitdiff
path: root/together/node_modules/formidable/src/parsers/Querystring.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
committerMinteck <contact@minteck.org>2022-08-21 17:31:56 +0200
commita2df9a69dcc14cb70118cda2ded499055e7ee358 (patch)
tree6dd283e4e9452d38bce81ddaaae49b5335755842 /together/node_modules/formidable/src/parsers/Querystring.js
parent84dd0735820b16b60f600284d35183d76547a71f (diff)
downloadpluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2
pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip
m. update
Diffstat (limited to 'together/node_modules/formidable/src/parsers/Querystring.js')
-rw-r--r--together/node_modules/formidable/src/parsers/Querystring.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/together/node_modules/formidable/src/parsers/Querystring.js b/together/node_modules/formidable/src/parsers/Querystring.js
new file mode 100644
index 0000000..a0d4243
--- /dev/null
+++ b/together/node_modules/formidable/src/parsers/Querystring.js
@@ -0,0 +1,38 @@
+/* eslint-disable no-underscore-dangle */
+
+'use strict';
+
+const { Transform } = require('stream');
+const querystring = require('querystring');
+
+// This is a buffering parser, not quite as nice as the multipart one.
+// If I find time I'll rewrite this to be fully streaming as well
+class QuerystringParser extends Transform {
+ constructor(options = {}) {
+ super({ readableObjectMode: true });
+ this.globalOptions = { ...options };
+ this.buffer = '';
+ this.bufferLength = 0;
+ }
+
+ _transform(buffer, encoding, callback) {
+ this.buffer += buffer.toString('ascii');
+ this.bufferLength = this.buffer.length;
+ callback();
+ }
+
+ _flush(callback) {
+ const fields = querystring.parse(this.buffer, '&', '=');
+ // eslint-disable-next-line no-restricted-syntax, guard-for-in
+ for (const key in fields) {
+ this.push({
+ key,
+ value: fields[key],
+ });
+ }
+ this.buffer = '';
+ callback();
+ }
+}
+
+module.exports = QuerystringParser;