| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1c07724 commit 9788e96
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1116,6 +1116,11 @@ API] [`URLSearchParams` constructor][`new URLSearchParams(iterable)`] does not | |||
| 1116 | 1116 | represent a `[name, value]` tuple – that is, if an element is not iterable, or | |
| 1117 | 1117 | does not consist of exactly two elements. | |
| 1118 | 1118 | ||
| 1119 | + <a id="ERR_INVALID_URI"></a> | ||
| 1120 | + ### ERR_INVALID_URI | ||
| 1121 | + | ||
| 1122 | + Used when an invalid URI is passed. | ||
| 1123 | + | ||
| 1119 | 1124 | <a id="ERR_INVALID_URL"></a> | |
| 1120 | 1125 | ### ERR_INVALID_URL | |
| 1121 | 1126 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,6 +126,7 @@ module.exports = exports = { | |||
| 126 | 126 | Error: makeNodeError(Error), | |
| 127 | 127 | TypeError: makeNodeError(TypeError), | |
| 128 | 128 | RangeError: makeNodeError(RangeError), | |
| 129 | + URIError: makeNodeError(URIError), | ||
| 129 | 130 | AssertionError, | |
| 130 | 131 | E // This is exported only to facilitate testing. | |
| 131 | 132 | }; | |
@@ -287,6 +288,7 @@ E('ERR_INVALID_SYNC_FORK_INPUT', | |||
| 287 | 288 | 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s'); | |
| 288 | 289 | E('ERR_INVALID_THIS', 'Value of "this" must be of type %s'); | |
| 289 | 290 | E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple'); | |
| 291 | + E('ERR_INVALID_URI', 'URI malformed'); | ||
| 290 | 292 | E('ERR_INVALID_URL', 'Invalid URL: %s'); | |
| 291 | 293 | E('ERR_INVALID_URL_SCHEME', | |
| 292 | 294 | (expected) => `The URL must be ${oneOf(expected, 'scheme')}`); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | 'use strict'; | |
| 25 | 25 | ||
| 26 | 26 | const { Buffer } = require('buffer'); | |
| 27 | + const errors = require('internal/errors'); | ||
| 27 | 28 | const { | |
| 28 | 29 | hexTable, | |
| 29 | 30 | isHexTable | |
@@ -174,11 +175,12 @@ function qsEscape(str) { | |||
| 174 | 175 | } | |
| 175 | 176 | // Surrogate pair | |
| 176 | 177 | ++i; | |
| 177 | - var c2; | ||
| 178 | - if (i < str.length) | ||
| 179 | - c2 = str.charCodeAt(i) & 0x3FF; | ||
| 180 | - else | ||
| 181 | - throw new URIError('URI malformed'); | ||
| 178 | + | ||
| 179 | + if (i >= str.length) | ||
| 180 | + throw new errors.URIError('ERR_INVALID_URI'); | ||
| 181 | + | ||
| 182 | + var c2 = str.charCodeAt(i) & 0x3FF; | ||
| 183 | + | ||
| 182 | 184 | lastPos = i + 1; | |
| 183 | 185 | c = 0x10000 + (((c & 0x3FF) << 10) | c2); | |
| 184 | 186 | out += hexTable[0xF0 | (c >> 18)] + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | ||
| 5 | 5 | const qs = require('querystring'); | |
@@ -12,8 +12,15 @@ assert.deepStrictEqual(qs.escape('Ŋōđĕ'), '%C5%8A%C5%8D%C4%91%C4%95'); | |||
| 12 | 12 | assert.deepStrictEqual(qs.escape('testŊōđĕ'), 'test%C5%8A%C5%8D%C4%91%C4%95'); | |
| 13 | 13 | assert.deepStrictEqual(qs.escape(`${String.fromCharCode(0xD800 + 1)}test`), | |
| 14 | 14 | '%F0%90%91%B4est'); | |
| 15 | - assert.throws(() => qs.escape(String.fromCharCode(0xD800 + 1)), | ||
| 16 | - /^URIError: URI malformed$/); | ||
| 15 | + | ||
| 16 | + common.expectsError( | ||
| 17 | + () => qs.escape(String.fromCharCode(0xD800 + 1)), | ||
| 18 | + { | ||
| 19 | + code: 'ERR_INVALID_URI', | ||
| 20 | + type: URIError, | ||
| 21 | + message: 'URI malformed' | ||
| 22 | + } | ||
| 23 | + ); | ||
| 17 | 24 | ||
| 18 | 25 | // using toString for objects | |
| 19 | 26 | assert.strictEqual( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ | |||
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | - require('../common'); | ||
| 23 | + const common = require('../common'); | ||
| 24 | 24 | const assert = require('assert'); | |
| 25 | 25 | const inspect = require('util').inspect; | |
| 26 | 26 | ||
@@ -271,9 +271,14 @@ qsWeirdObjects.forEach(function(testCase) { | |||
| 271 | 271 | }); | |
| 272 | 272 | ||
| 273 | 273 | // invalid surrogate pair throws URIError | |
| 274 | - assert.throws(function() { | ||
| 275 | - qs.stringify({ foo: '\udc00' }); | ||
| 276 | - }, /^URIError: URI malformed$/); | ||
| 274 | + common.expectsError( | ||
| 275 | + () => qs.stringify({ foo: '\udc00' }), | ||
| 276 | + { | ||
| 277 | + code: 'ERR_INVALID_URI', | ||
| 278 | + type: URIError, | ||
| 279 | + message: 'URI malformed' | ||
| 280 | + } | ||
| 281 | + ); | ||
| 277 | 282 | ||
| 278 | 283 | // coerce numbers to string | |
| 279 | 284 | assert.strictEqual('foo=0', qs.stringify({ foo: 0 })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments