Skip to content

Commit b43cdee

Browse files
committed
Address comments
1 parent 71a31ff commit b43cdee

15 files changed

+32
-34
lines changed

doc/api/errors.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,7 @@ semantics for determining whether a path can be used is platform-dependent.
602602
### ERR_INVALID_THIS
603603

604604
The `'ERR_INVALID_THIS'` error code is used generically to identify that a
605-
Node.js API function is called with an incompatible `this` value. Its use is
606-
currently limited to the [WHATWG URL API][] to satisfy specification
607-
requirements, but may be expanded to other areas of the Node.js API in the
608-
future.
605+
Node.js API function is called with an incompatible `this` value.
609606

610607
Example:
611608

@@ -623,9 +620,9 @@ urlSearchParams.has.call(buf, 'foo');
623620

624621
An error with code `'ERR_INVALID_TUPLE'` is thrown when an element in the
625622
`iterable` provided to the [WHATWG][WHATWG URL API] [`URLSearchParams`
626-
constructor][`new URLSearchParams(iterable)`] does not represent a name/value
627-
tuple -- that is, if an element is not iterable, or does not consist of exactly
628-
two elements.
623+
constructor][`new URLSearchParams(iterable)`] does not represent a `[name,
624+
value]` tuple that is, if an element is not iterable, or does not consist of
625+
exactly two elements.
629626

630627
<a id="ERR_INVALID_URL"></a>
631628
### ERR_INVALID_URL

lib/internal/errors.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');
8383
E('ERR_ASSERTION', (msg) => msg);
8484
E('ERR_INVALID_ARG_TYPE', invalidArgType);
8585
E('ERR_INVALID_CALLBACK', 'callback must be a function');
86-
E('ERR_INVALID_FILE_URL_HOST', 'File URL host must %s');
87-
E('ERR_INVALID_FILE_URL_PATH', 'File URL path must %s');
88-
E('ERR_INVALID_THIS', 'Value of this must be of type %s');
86+
E('ERR_INVALID_FILE_URL_HOST', 'File URL host %s');
87+
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s');
88+
E('ERR_INVALID_THIS', 'Value of "this" must be of type %s');
8989
E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple');
90-
E('ERR_INVALID_URL',
91-
(input) => `Invalid URL${input !== undefined ? `: ${input}` : ''}`);
90+
E('ERR_INVALID_URL', 'Invalid URL: %s');
9291
E('ERR_INVALID_URL_SCHEME',
9392
(expected) => `The URL must be ${oneOf(expected, 'scheme')}`);
9493
E('ERR_MISSING_ARGS', missingArgs);

lib/internal/url.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ class URLSearchParams {
821821
if (typeof pair !== 'object' ||
822822
typeof pair[Symbol.iterator] !== 'function') {
823823
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
824-
'name/value');
824+
'[name, value]');
825825
}
826826
pairs.push(Array.from(pair));
827827
}
@@ -830,7 +830,7 @@ class URLSearchParams {
830830
for (const pair of pairs) {
831831
if (pair.length !== 2) {
832832
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
833-
'name/value');
833+
'[name, value]');
834834
}
835835
const key = toUSVString(pair[0]);
836836
const value = toUSVString(pair[1]);
@@ -1302,8 +1302,9 @@ function getPathFromURLWin32(url) {
13021302
var third = pathname.codePointAt(n + 2) | 0x20;
13031303
if ((pathname[n + 1] === '2' && third === 102) || // 2f 2F /
13041304
(pathname[n + 1] === '5' && third === 99)) { // 5c 5C \
1305-
return new errors.TypeError('ERR_INVALID_FILE_URL_PATH',
1306-
'not include encoded \\ or / characters');
1305+
return new errors.TypeError(
1306+
'ERR_INVALID_FILE_URL_PATH',
1307+
'must not include encoded \\ or / characters');
13071308
}
13081309
}
13091310
}
@@ -1322,7 +1323,8 @@ function getPathFromURLWin32(url) {
13221323
var sep = pathname[2];
13231324
if (letter < 97 || letter > 122 || // a..z A..Z
13241325
(sep !== ':')) {
1325-
return new errors.TypeError('ERR_INVALID_FILE_URL_PATH', 'be absolute');
1326+
return new errors.TypeError('ERR_INVALID_FILE_URL_PATH',
1327+
'must be absolute');
13261328
}
13271329
return pathname.slice(1);
13281330
}
@@ -1331,15 +1333,15 @@ function getPathFromURLWin32(url) {
13311333
function getPathFromURLPosix(url) {
13321334
if (url.hostname !== '') {
13331335
return new errors.TypeError('ERR_INVALID_FILE_URL_HOST',
1334-
`be "localhost" or empty on ${platform}`);
1336+
`must be "localhost" or empty on ${platform}`);
13351337
}
13361338
var pathname = url.pathname;
13371339
for (var n = 0; n < pathname.length; n++) {
13381340
if (pathname[n] === '%') {
13391341
var third = pathname.codePointAt(n + 2) | 0x20;
13401342
if (pathname[n + 1] === '2' && third === 102) {
13411343
return new errors.TypeError('ERR_INVALID_FILE_URL_PATH',
1342-
'not include encoded / characters');
1344+
'must not include encoded / characters');
13431345
}
13441346
}
13451347
}

test/parallel/test-whatwg-url-searchparams-append.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test(function() {
5656
}, common.expectsError({
5757
code: 'ERR_INVALID_THIS',
5858
type: TypeError,
59-
message: 'Value of this must be of type URLSearchParams'
59+
message: 'Value of "this" must be of type URLSearchParams'
6060
}));
6161
assert.throws(() => {
6262
params.append('a');

test/parallel/test-whatwg-url-searchparams-constructor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test(() => {
196196
const tupleError = common.expectsError({
197197
code: 'ERR_INVALID_TUPLE',
198198
type: TypeError,
199-
message: 'Each query pair must be an iterable name/value tuple'
199+
message: 'Each query pair must be an iterable [name, value] tuple'
200200
});
201201

202202
let params;

test/parallel/test-whatwg-url-searchparams-delete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test(function() {
5050
}, common.expectsError({
5151
code: 'ERR_INVALID_THIS',
5252
type: TypeError,
53-
message: 'Value of this must be of type URLSearchParams'
53+
message: 'Value of "this" must be of type URLSearchParams'
5454
}));
5555
assert.throws(() => {
5656
params.delete();

test/parallel/test-whatwg-url-searchparams-entries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ assert.throws(() => {
3131
}, common.expectsError({
3232
code: 'ERR_INVALID_THIS',
3333
type: TypeError,
34-
message: 'Value of this must be of type URLSearchParamsIterator'
34+
message: 'Value of "this" must be of type URLSearchParamsIterator'
3535
}));
3636
assert.throws(() => {
3737
params.entries.call(undefined);
3838
}, common.expectsError({
3939
code: 'ERR_INVALID_THIS',
4040
type: TypeError,
41-
message: 'Value of this must be of type URLSearchParams'
41+
message: 'Value of "this" must be of type URLSearchParams'
4242
}));

test/parallel/test-whatwg-url-searchparams-foreach.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ test(function() {
5353
}, common.expectsError({
5454
code: 'ERR_INVALID_THIS',
5555
type: TypeError,
56-
message: 'Value of this must be of type URLSearchParams'
56+
message: 'Value of "this" must be of type URLSearchParams'
5757
}));
5858
}

test/parallel/test-whatwg-url-searchparams-get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test(function() {
4141
}, common.expectsError({
4242
code: 'ERR_INVALID_THIS',
4343
type: TypeError,
44-
message: 'Value of this must be of type URLSearchParams'
44+
message: 'Value of "this" must be of type URLSearchParams'
4545
}));
4646
assert.throws(() => {
4747
params.get();

test/parallel/test-whatwg-url-searchparams-getall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test(function() {
4545
}, common.expectsError({
4646
code: 'ERR_INVALID_THIS',
4747
type: TypeError,
48-
message: 'Value of this must be of type URLSearchParams'
48+
message: 'Value of "this" must be of type URLSearchParams'
4949
}));
5050
assert.throws(() => {
5151
params.getAll();

test/parallel/test-whatwg-url-searchparams-has.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test(function() {
4444
}, common.expectsError({
4545
code: 'ERR_INVALID_THIS',
4646
type: TypeError,
47-
message: 'Value of this must be of type URLSearchParams'
47+
message: 'Value of "this" must be of type URLSearchParams'
4848
}));
4949
assert.throws(() => {
5050
params.has();

test/parallel/test-whatwg-url-searchparams-keys.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ assert.throws(() => {
3232
}, common.expectsError({
3333
code: 'ERR_INVALID_THIS',
3434
type: TypeError,
35-
message: 'Value of this must be of type URLSearchParamsIterator'
35+
message: 'Value of "this" must be of type URLSearchParamsIterator'
3636
}));
3737
assert.throws(() => {
3838
params.keys.call(undefined);
3939
}, common.expectsError({
4040
code: 'ERR_INVALID_THIS',
4141
type: TypeError,
42-
message: 'Value of this must be of type URLSearchParams'
42+
message: 'Value of "this" must be of type URLSearchParams'
4343
}));

test/parallel/test-whatwg-url-searchparams-set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test(function() {
4242
}, common.expectsError({
4343
code: 'ERR_INVALID_THIS',
4444
type: TypeError,
45-
message: 'Value of this must be of type URLSearchParams'
45+
message: 'Value of "this" must be of type URLSearchParams'
4646
}));
4747
assert.throws(() => {
4848
params.set('a');

test/parallel/test-whatwg-url-searchparams-stringifier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ test(function() {
130130
}, common.expectsError({
131131
code: 'ERR_INVALID_THIS',
132132
type: TypeError,
133-
message: 'Value of this must be of type URLSearchParams'
133+
message: 'Value of "this" must be of type URLSearchParams'
134134
}));
135135
}

test/parallel/test-whatwg-url-searchparams-values.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ assert.throws(() => {
3232
}, common.expectsError({
3333
code: 'ERR_INVALID_THIS',
3434
type: TypeError,
35-
message: 'Value of this must be of type URLSearchParamsIterator'
35+
message: 'Value of "this" must be of type URLSearchParamsIterator'
3636
}));
3737
assert.throws(() => {
3838
params.values.call(undefined);
3939
}, common.expectsError({
4040
code: 'ERR_INVALID_THIS',
4141
type: TypeError,
42-
message: 'Value of this must be of type URLSearchParams'
42+
message: 'Value of "this" must be of type URLSearchParams'
4343
}));

0 commit comments

Comments
 (0)