summaryrefslogtreecommitdiff
path: root/lib/internal/querystring.js
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2017-02-03 22:06:04 -0800
committerTimothy Gu <timothygu99@gmail.com>2017-02-14 12:13:11 -0800
commitc6b12d0984cc2891433b57cf344b433059681667 (patch)
tree676f8de002d49b555ca931c05410e7e227da7cd2 /lib/internal/querystring.js
parentb738cbcdd381a3bcef0111d75d5081bec70d8ce4 (diff)
downloadandroid-node-v8-c6b12d0984cc2891433b57cf344b433059681667.tar.gz
android-node-v8-c6b12d0984cc2891433b57cf344b433059681667.tar.bz2
android-node-v8-c6b12d0984cc2891433b57cf344b433059681667.zip
url: fix surrogate handling in encodeAuth()
Also factor out common parts in querystring and url. PR-URL: https://github.com/nodejs/node/pull/11161 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'lib/internal/querystring.js')
-rw-r--r--lib/internal/querystring.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/internal/querystring.js b/lib/internal/querystring.js
new file mode 100644
index 0000000000..2f8d77d3e9
--- /dev/null
+++ b/lib/internal/querystring.js
@@ -0,0 +1,15 @@
+'use strict';
+
+const hexTable = new Array(256);
+for (var i = 0; i < 256; ++i)
+ hexTable[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
+
+// Instantiating this is faster than explicitly calling `Object.create(null)`
+// to get a "clean" empty object (tested with v8 v4.9).
+function StorageObject() {}
+StorageObject.prototype = Object.create(null);
+
+module.exports = {
+ hexTable,
+ StorageObject
+};