aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/parseqs/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/parseqs/index.js')
-rw-r--r--node_modules/parseqs/index.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/node_modules/parseqs/index.js b/node_modules/parseqs/index.js
new file mode 100644
index 0000000..e0b366e
--- /dev/null
+++ b/node_modules/parseqs/index.js
@@ -0,0 +1,37 @@
+/**
+ * Compiles a querystring
+ * Returns string representation of the object
+ *
+ * @param {Object}
+ * @api private
+ */
+
+exports.encode = function (obj) {
+ var str = '';
+
+ for (var i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ if (str.length) str += '&';
+ str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
+ }
+ }
+
+ return str;
+};
+
+/**
+ * Parses a simple querystring into an object
+ *
+ * @param {String} qs
+ * @api private
+ */
+
+exports.decode = function(qs){
+ var qry = {};
+ var pairs = qs.split('&');
+ for (var i = 0, l = pairs.length; i < l; i++) {
+ var pair = pairs[i].split('=');
+ qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
+ }
+ return qry;
+};