summaryrefslogtreecommitdiff
path: root/lib/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/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/querystring.js')
-rw-r--r--lib/querystring.js15
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/querystring.js b/lib/querystring.js
index 32ba307120..0e94dcd0f1 100644
--- a/lib/querystring.js
+++ b/lib/querystring.js
@@ -1,5 +1,7 @@
'use strict';
+const { Buffer } = require('buffer');
+const { StorageObject, hexTable } = require('internal/querystring');
const QueryString = module.exports = {
unescapeBuffer,
// `unescape()` is a JS global, so we need to use a different local name
@@ -14,13 +16,6 @@ const QueryString = module.exports = {
parse,
decode: parse
};
-const Buffer = require('buffer').Buffer;
-
-// This constructor is used to store parsed query string values. Instantiating
-// this is faster than explicitly calling `Object.create(null)` to get a
-// "clean" empty object (tested with v8 v4.9).
-function ParsedQueryString() {}
-ParsedQueryString.prototype = Object.create(null);
const unhexTable = [
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0 - 15
@@ -116,10 +111,6 @@ function qsUnescape(s, decodeSpaces) {
}
-const hexTable = [];
-for (var i = 0; i < 256; ++i)
- hexTable[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
-
// These characters do not need escaping when generating query strings:
// ! - . _ ~
// ' ( ) *
@@ -282,7 +273,7 @@ const defEqCodes = [61]; // =
// Parse a key/val string.
function parse(qs, sep, eq, options) {
- const obj = new ParsedQueryString();
+ const obj = new StorageObject();
if (typeof qs !== 'string' || qs.length === 0) {
return obj;