core-js 3.32.0 → 3.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internals/add-to-unscopables.js +1 -1
- package/internals/array-buffer-byte-length.js +1 -1
- package/internals/array-buffer-transfer.js +1 -1
- package/internals/array-buffer.js +1 -1
- package/internals/array-includes.js +2 -2
- package/internals/array-iteration-from-last.js +1 -1
- package/internals/array-iteration.js +7 -7
- package/internals/array-slice-simple.js +2 -1
- package/internals/async-iterator-iteration.js +4 -4
- package/internals/caller.js +1 -1
- package/internals/check-correctness-of-iteration.js +3 -1
- package/internals/classof.js +2 -2
- package/internals/collection-strong.js +5 -5
- package/internals/collection.js +6 -6
- package/internals/date-to-iso-string.js +1 -1
- package/internals/descriptors.js +1 -1
- package/internals/engine-is-node.js +2 -1
- package/internals/fix-regexp-well-known-symbol-logic.js +5 -2
- package/internals/function-bind.js +3 -1
- package/internals/get-json-replacer-function.js +1 -1
- package/internals/get-set-record.js +1 -1
- package/internals/global.js +1 -1
- package/internals/host-report-errors.js +1 -1
- package/internals/ie8-dom-define.js +1 -1
- package/internals/ieee754.js +25 -14
- package/internals/indexed-object.js +1 -1
- package/internals/is-array.js +1 -1
- package/internals/is-big-int-array.js +1 -1
- package/internals/is-forced.js +2 -2
- package/internals/is-regexp.js +1 -1
- package/internals/iterator-define.js +7 -4
- package/internals/math-expm1.js +3 -2
- package/internals/math-fround.js +1 -1
- package/internals/math-scale.js +1 -1
- package/internals/math-sign.js +1 -1
- package/internals/number-parse-float.js +1 -1
- package/internals/numeric-range-iterator.js +1 -1
- package/internals/object-assign.js +2 -2
- package/internals/object-get-own-property-names-external.js +1 -1
- package/internals/object-is-extensible.js +1 -1
- package/internals/parse-json-string.js +3 -3
- package/internals/regexp-sticky-helpers.js +2 -2
- package/internals/same-value-zero.js +1 -1
- package/internals/same-value.js +1 -1
- package/internals/schedulers-fix.js +1 -1
- package/internals/shared.js +2 -2
- package/internals/string-pad.js +1 -1
- package/internals/string-punycode-to-ascii.js +4 -4
- package/internals/string-repeat.js +1 -1
- package/internals/structured-clone-proper-transfer.js +1 -1
- package/internals/symbol-constructor-detection.js +1 -1
- package/internals/symbol-is-well-known.js +1 -0
- package/internals/typed-array-constructor.js +2 -2
- package/internals/v8-prototype-define-bug.js +1 -1
- package/modules/es.array.for-each.js +1 -1
- package/modules/es.array.iterator.js +4 -3
- package/modules/es.array.join.js +1 -1
- package/modules/es.date.set-year.js +1 -1
- package/modules/es.date.to-string.js +1 -1
- package/modules/es.json.stringify.js +4 -4
- package/modules/es.math.acosh.js +2 -2
- package/modules/es.math.asinh.js +1 -1
- package/modules/es.math.atanh.js +1 -1
- package/modules/es.math.expm1.js +1 -1
- package/modules/es.math.imul.js +1 -1
- package/modules/es.math.sinh.js +1 -1
- package/modules/es.math.tanh.js +1 -1
- package/modules/es.number.constructor.js +14 -3
- package/modules/es.number.is-nan.js +1 -1
- package/modules/es.number.parse-float.js +1 -1
- package/modules/es.number.parse-int.js +1 -1
- package/modules/es.number.to-fixed.js +1 -1
- package/modules/es.object.is-frozen.js +1 -1
- package/modules/es.object.is-sealed.js +1 -1
- package/modules/es.parse-float.js +1 -1
- package/modules/es.parse-int.js +1 -1
- package/modules/es.promise.constructor.js +2 -2
- package/modules/es.reflect.construct.js +1 -1
- package/modules/es.regexp.constructor.js +2 -2
- package/modules/es.regexp.to-string.js +2 -2
- package/modules/es.string.from-code-point.js +1 -1
- package/modules/es.string.is-well-formed.js +2 -2
- package/modules/es.string.match-all.js +1 -1
- package/modules/es.string.replace.js +8 -3
- package/modules/es.string.split.js +4 -4
- package/modules/es.string.to-well-formed.js +2 -2
- package/modules/es.symbol.constructor.js +1 -1
- package/modules/es.symbol.description.js +1 -1
- package/modules/es.typed-array.to-locale-string.js +1 -1
- package/modules/es.typed-array.to-string.js +1 -1
- package/modules/es.weak-map.constructor.js +2 -2
- package/modules/esnext.array.last-index.js +1 -1
- package/modules/esnext.array.last-item.js +2 -2
- package/modules/esnext.async-disposable-stack.constructor.js +3 -3
- package/modules/esnext.composite-symbol.js +1 -1
- package/modules/esnext.disposable-stack.constructor.js +3 -3
- package/modules/esnext.json.parse.js +15 -15
- package/modules/esnext.json.raw-json.js +3 -3
- package/modules/esnext.math.signbit.js +1 -1
- package/modules/esnext.number.from-string.js +1 -1
- package/modules/esnext.set.intersection.v2.js +1 -1
- package/modules/esnext.string.dedent.js +8 -3
- package/modules/web.atob.js +2 -2
- package/modules/web.dom-exception.constructor.js +1 -1
- package/modules/web.structured-clone.js +4 -4
- package/modules/web.url.constructor.js +129 -125
- package/package.json +1 -1
- package/postinstall.js +1 -0
|
@@ -71,7 +71,7 @@ var EOF;
|
|
|
71
71
|
var parseIPv4 = function (input) {
|
|
72
72
|
var parts = split(input, '.');
|
|
73
73
|
var partsLength, numbers, index, part, radix, number, ipv4;
|
|
74
|
-
if (parts.length && parts[parts.length - 1]
|
|
74
|
+
if (parts.length && parts[parts.length - 1] === '') {
|
|
75
75
|
parts.length--;
|
|
76
76
|
}
|
|
77
77
|
partsLength = parts.length;
|
|
@@ -79,23 +79,23 @@ var parseIPv4 = function (input) {
|
|
|
79
79
|
numbers = [];
|
|
80
80
|
for (index = 0; index < partsLength; index++) {
|
|
81
81
|
part = parts[index];
|
|
82
|
-
if (part
|
|
82
|
+
if (part === '') return input;
|
|
83
83
|
radix = 10;
|
|
84
|
-
if (part.length > 1 && charAt(part, 0)
|
|
84
|
+
if (part.length > 1 && charAt(part, 0) === '0') {
|
|
85
85
|
radix = exec(HEX_START, part) ? 16 : 8;
|
|
86
|
-
part = stringSlice(part, radix
|
|
86
|
+
part = stringSlice(part, radix === 8 ? 1 : 2);
|
|
87
87
|
}
|
|
88
88
|
if (part === '') {
|
|
89
89
|
number = 0;
|
|
90
90
|
} else {
|
|
91
|
-
if (!exec(radix
|
|
91
|
+
if (!exec(radix === 10 ? DEC : radix === 8 ? OCT : HEX, part)) return input;
|
|
92
92
|
number = parseInt(part, radix);
|
|
93
93
|
}
|
|
94
94
|
push(numbers, number);
|
|
95
95
|
}
|
|
96
96
|
for (index = 0; index < partsLength; index++) {
|
|
97
97
|
number = numbers[index];
|
|
98
|
-
if (index
|
|
98
|
+
if (index === partsLength - 1) {
|
|
99
99
|
if (number >= pow(256, 5 - partsLength)) return null;
|
|
100
100
|
} else if (number > 255) return null;
|
|
101
101
|
}
|
|
@@ -119,15 +119,15 @@ var parseIPv6 = function (input) {
|
|
|
119
119
|
return charAt(input, pointer);
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
if (chr()
|
|
123
|
-
if (charAt(input, 1)
|
|
122
|
+
if (chr() === ':') {
|
|
123
|
+
if (charAt(input, 1) !== ':') return;
|
|
124
124
|
pointer += 2;
|
|
125
125
|
pieceIndex++;
|
|
126
126
|
compress = pieceIndex;
|
|
127
127
|
}
|
|
128
128
|
while (chr()) {
|
|
129
|
-
if (pieceIndex
|
|
130
|
-
if (chr()
|
|
129
|
+
if (pieceIndex === 8) return;
|
|
130
|
+
if (chr() === ':') {
|
|
131
131
|
if (compress !== null) return;
|
|
132
132
|
pointer++;
|
|
133
133
|
pieceIndex++;
|
|
@@ -140,33 +140,33 @@ var parseIPv6 = function (input) {
|
|
|
140
140
|
pointer++;
|
|
141
141
|
length++;
|
|
142
142
|
}
|
|
143
|
-
if (chr()
|
|
144
|
-
if (length
|
|
143
|
+
if (chr() === '.') {
|
|
144
|
+
if (length === 0) return;
|
|
145
145
|
pointer -= length;
|
|
146
146
|
if (pieceIndex > 6) return;
|
|
147
147
|
numbersSeen = 0;
|
|
148
148
|
while (chr()) {
|
|
149
149
|
ipv4Piece = null;
|
|
150
150
|
if (numbersSeen > 0) {
|
|
151
|
-
if (chr()
|
|
151
|
+
if (chr() === '.' && numbersSeen < 4) pointer++;
|
|
152
152
|
else return;
|
|
153
153
|
}
|
|
154
154
|
if (!exec(DIGIT, chr())) return;
|
|
155
155
|
while (exec(DIGIT, chr())) {
|
|
156
156
|
number = parseInt(chr(), 10);
|
|
157
157
|
if (ipv4Piece === null) ipv4Piece = number;
|
|
158
|
-
else if (ipv4Piece
|
|
158
|
+
else if (ipv4Piece === 0) return;
|
|
159
159
|
else ipv4Piece = ipv4Piece * 10 + number;
|
|
160
160
|
if (ipv4Piece > 255) return;
|
|
161
161
|
pointer++;
|
|
162
162
|
}
|
|
163
163
|
address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
|
|
164
164
|
numbersSeen++;
|
|
165
|
-
if (numbersSeen
|
|
165
|
+
if (numbersSeen === 2 || numbersSeen === 4) pieceIndex++;
|
|
166
166
|
}
|
|
167
|
-
if (numbersSeen
|
|
167
|
+
if (numbersSeen !== 4) return;
|
|
168
168
|
break;
|
|
169
|
-
} else if (chr()
|
|
169
|
+
} else if (chr() === ':') {
|
|
170
170
|
pointer++;
|
|
171
171
|
if (!chr()) return;
|
|
172
172
|
} else if (chr()) return;
|
|
@@ -175,12 +175,12 @@ var parseIPv6 = function (input) {
|
|
|
175
175
|
if (compress !== null) {
|
|
176
176
|
swaps = pieceIndex - compress;
|
|
177
177
|
pieceIndex = 7;
|
|
178
|
-
while (pieceIndex
|
|
178
|
+
while (pieceIndex !== 0 && swaps > 0) {
|
|
179
179
|
swap = address[pieceIndex];
|
|
180
180
|
address[pieceIndex--] = address[compress + swaps - 1];
|
|
181
181
|
address[compress + --swaps] = swap;
|
|
182
182
|
}
|
|
183
|
-
} else if (pieceIndex
|
|
183
|
+
} else if (pieceIndex !== 8) return;
|
|
184
184
|
return address;
|
|
185
185
|
};
|
|
186
186
|
|
|
@@ -268,15 +268,15 @@ var specialSchemes = {
|
|
|
268
268
|
// https://url.spec.whatwg.org/#windows-drive-letter
|
|
269
269
|
var isWindowsDriveLetter = function (string, normalized) {
|
|
270
270
|
var second;
|
|
271
|
-
return string.length
|
|
272
|
-
&& ((second = charAt(string, 1))
|
|
271
|
+
return string.length === 2 && exec(ALPHA, charAt(string, 0))
|
|
272
|
+
&& ((second = charAt(string, 1)) === ':' || (!normalized && second === '|'));
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
|
|
276
276
|
var startsWithWindowsDriveLetter = function (string) {
|
|
277
277
|
var third;
|
|
278
278
|
return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (
|
|
279
|
-
string.length
|
|
279
|
+
string.length === 2 ||
|
|
280
280
|
((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#')
|
|
281
281
|
);
|
|
282
282
|
};
|
|
@@ -380,27 +380,27 @@ URLState.prototype = {
|
|
|
380
380
|
break;
|
|
381
381
|
|
|
382
382
|
case SCHEME:
|
|
383
|
-
if (chr && (exec(ALPHANUMERIC, chr) || chr
|
|
383
|
+
if (chr && (exec(ALPHANUMERIC, chr) || chr === '+' || chr === '-' || chr === '.')) {
|
|
384
384
|
buffer += toLowerCase(chr);
|
|
385
|
-
} else if (chr
|
|
385
|
+
} else if (chr === ':') {
|
|
386
386
|
if (stateOverride && (
|
|
387
|
-
(url.isSpecial()
|
|
388
|
-
(buffer
|
|
389
|
-
(url.scheme
|
|
387
|
+
(url.isSpecial() !== hasOwn(specialSchemes, buffer)) ||
|
|
388
|
+
(buffer === 'file' && (url.includesCredentials() || url.port !== null)) ||
|
|
389
|
+
(url.scheme === 'file' && !url.host)
|
|
390
390
|
)) return;
|
|
391
391
|
url.scheme = buffer;
|
|
392
392
|
if (stateOverride) {
|
|
393
|
-
if (url.isSpecial() && specialSchemes[url.scheme]
|
|
393
|
+
if (url.isSpecial() && specialSchemes[url.scheme] === url.port) url.port = null;
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
396
|
buffer = '';
|
|
397
|
-
if (url.scheme
|
|
397
|
+
if (url.scheme === 'file') {
|
|
398
398
|
state = FILE;
|
|
399
|
-
} else if (url.isSpecial() && base && base.scheme
|
|
399
|
+
} else if (url.isSpecial() && base && base.scheme === url.scheme) {
|
|
400
400
|
state = SPECIAL_RELATIVE_OR_AUTHORITY;
|
|
401
401
|
} else if (url.isSpecial()) {
|
|
402
402
|
state = SPECIAL_AUTHORITY_SLASHES;
|
|
403
|
-
} else if (codePoints[pointer + 1]
|
|
403
|
+
} else if (codePoints[pointer + 1] === '/') {
|
|
404
404
|
state = PATH_OR_AUTHORITY;
|
|
405
405
|
pointer++;
|
|
406
406
|
} else {
|
|
@@ -417,8 +417,8 @@ URLState.prototype = {
|
|
|
417
417
|
break;
|
|
418
418
|
|
|
419
419
|
case NO_SCHEME:
|
|
420
|
-
if (!base || (base.cannotBeABaseURL && chr
|
|
421
|
-
if (base.cannotBeABaseURL && chr
|
|
420
|
+
if (!base || (base.cannotBeABaseURL && chr !== '#')) return INVALID_SCHEME;
|
|
421
|
+
if (base.cannotBeABaseURL && chr === '#') {
|
|
422
422
|
url.scheme = base.scheme;
|
|
423
423
|
url.path = arraySlice(base.path);
|
|
424
424
|
url.query = base.query;
|
|
@@ -427,11 +427,11 @@ URLState.prototype = {
|
|
|
427
427
|
state = FRAGMENT;
|
|
428
428
|
break;
|
|
429
429
|
}
|
|
430
|
-
state = base.scheme
|
|
430
|
+
state = base.scheme === 'file' ? FILE : RELATIVE;
|
|
431
431
|
continue;
|
|
432
432
|
|
|
433
433
|
case SPECIAL_RELATIVE_OR_AUTHORITY:
|
|
434
|
-
if (chr
|
|
434
|
+
if (chr === '/' && codePoints[pointer + 1] === '/') {
|
|
435
435
|
state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
|
|
436
436
|
pointer++;
|
|
437
437
|
} else {
|
|
@@ -440,7 +440,7 @@ URLState.prototype = {
|
|
|
440
440
|
} break;
|
|
441
441
|
|
|
442
442
|
case PATH_OR_AUTHORITY:
|
|
443
|
-
if (chr
|
|
443
|
+
if (chr === '/') {
|
|
444
444
|
state = AUTHORITY;
|
|
445
445
|
break;
|
|
446
446
|
} else {
|
|
@@ -450,16 +450,16 @@ URLState.prototype = {
|
|
|
450
450
|
|
|
451
451
|
case RELATIVE:
|
|
452
452
|
url.scheme = base.scheme;
|
|
453
|
-
if (chr
|
|
453
|
+
if (chr === EOF) {
|
|
454
454
|
url.username = base.username;
|
|
455
455
|
url.password = base.password;
|
|
456
456
|
url.host = base.host;
|
|
457
457
|
url.port = base.port;
|
|
458
458
|
url.path = arraySlice(base.path);
|
|
459
459
|
url.query = base.query;
|
|
460
|
-
} else if (chr
|
|
460
|
+
} else if (chr === '/' || (chr === '\\' && url.isSpecial())) {
|
|
461
461
|
state = RELATIVE_SLASH;
|
|
462
|
-
} else if (chr
|
|
462
|
+
} else if (chr === '?') {
|
|
463
463
|
url.username = base.username;
|
|
464
464
|
url.password = base.password;
|
|
465
465
|
url.host = base.host;
|
|
@@ -467,7 +467,7 @@ URLState.prototype = {
|
|
|
467
467
|
url.path = arraySlice(base.path);
|
|
468
468
|
url.query = '';
|
|
469
469
|
state = QUERY;
|
|
470
|
-
} else if (chr
|
|
470
|
+
} else if (chr === '#') {
|
|
471
471
|
url.username = base.username;
|
|
472
472
|
url.password = base.password;
|
|
473
473
|
url.host = base.host;
|
|
@@ -488,9 +488,9 @@ URLState.prototype = {
|
|
|
488
488
|
} break;
|
|
489
489
|
|
|
490
490
|
case RELATIVE_SLASH:
|
|
491
|
-
if (url.isSpecial() && (chr
|
|
491
|
+
if (url.isSpecial() && (chr === '/' || chr === '\\')) {
|
|
492
492
|
state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
|
|
493
|
-
} else if (chr
|
|
493
|
+
} else if (chr === '/') {
|
|
494
494
|
state = AUTHORITY;
|
|
495
495
|
} else {
|
|
496
496
|
url.username = base.username;
|
|
@@ -503,24 +503,24 @@ URLState.prototype = {
|
|
|
503
503
|
|
|
504
504
|
case SPECIAL_AUTHORITY_SLASHES:
|
|
505
505
|
state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
|
|
506
|
-
if (chr
|
|
506
|
+
if (chr !== '/' || charAt(buffer, pointer + 1) !== '/') continue;
|
|
507
507
|
pointer++;
|
|
508
508
|
break;
|
|
509
509
|
|
|
510
510
|
case SPECIAL_AUTHORITY_IGNORE_SLASHES:
|
|
511
|
-
if (chr
|
|
511
|
+
if (chr !== '/' && chr !== '\\') {
|
|
512
512
|
state = AUTHORITY;
|
|
513
513
|
continue;
|
|
514
514
|
} break;
|
|
515
515
|
|
|
516
516
|
case AUTHORITY:
|
|
517
|
-
if (chr
|
|
517
|
+
if (chr === '@') {
|
|
518
518
|
if (seenAt) buffer = '%40' + buffer;
|
|
519
519
|
seenAt = true;
|
|
520
520
|
bufferCodePoints = arrayFrom(buffer);
|
|
521
521
|
for (var i = 0; i < bufferCodePoints.length; i++) {
|
|
522
522
|
var codePoint = bufferCodePoints[i];
|
|
523
|
-
if (codePoint
|
|
523
|
+
if (codePoint === ':' && !seenPasswordToken) {
|
|
524
524
|
seenPasswordToken = true;
|
|
525
525
|
continue;
|
|
526
526
|
}
|
|
@@ -530,10 +530,10 @@ URLState.prototype = {
|
|
|
530
530
|
}
|
|
531
531
|
buffer = '';
|
|
532
532
|
} else if (
|
|
533
|
-
chr
|
|
534
|
-
(chr
|
|
533
|
+
chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
|
|
534
|
+
(chr === '\\' && url.isSpecial())
|
|
535
535
|
) {
|
|
536
|
-
if (seenAt && buffer
|
|
536
|
+
if (seenAt && buffer === '') return INVALID_AUTHORITY;
|
|
537
537
|
pointer -= arrayFrom(buffer).length + 1;
|
|
538
538
|
buffer = '';
|
|
539
539
|
state = HOST;
|
|
@@ -542,22 +542,22 @@ URLState.prototype = {
|
|
|
542
542
|
|
|
543
543
|
case HOST:
|
|
544
544
|
case HOSTNAME:
|
|
545
|
-
if (stateOverride && url.scheme
|
|
545
|
+
if (stateOverride && url.scheme === 'file') {
|
|
546
546
|
state = FILE_HOST;
|
|
547
547
|
continue;
|
|
548
|
-
} else if (chr
|
|
549
|
-
if (buffer
|
|
548
|
+
} else if (chr === ':' && !seenBracket) {
|
|
549
|
+
if (buffer === '') return INVALID_HOST;
|
|
550
550
|
failure = url.parseHost(buffer);
|
|
551
551
|
if (failure) return failure;
|
|
552
552
|
buffer = '';
|
|
553
553
|
state = PORT;
|
|
554
|
-
if (stateOverride
|
|
554
|
+
if (stateOverride === HOSTNAME) return;
|
|
555
555
|
} else if (
|
|
556
|
-
chr
|
|
557
|
-
(chr
|
|
556
|
+
chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
|
|
557
|
+
(chr === '\\' && url.isSpecial())
|
|
558
558
|
) {
|
|
559
|
-
if (url.isSpecial() && buffer
|
|
560
|
-
if (stateOverride && buffer
|
|
559
|
+
if (url.isSpecial() && buffer === '') return INVALID_HOST;
|
|
560
|
+
if (stateOverride && buffer === '' && (url.includesCredentials() || url.port !== null)) return;
|
|
561
561
|
failure = url.parseHost(buffer);
|
|
562
562
|
if (failure) return failure;
|
|
563
563
|
buffer = '';
|
|
@@ -565,8 +565,8 @@ URLState.prototype = {
|
|
|
565
565
|
if (stateOverride) return;
|
|
566
566
|
continue;
|
|
567
567
|
} else {
|
|
568
|
-
if (chr
|
|
569
|
-
else if (chr
|
|
568
|
+
if (chr === '[') seenBracket = true;
|
|
569
|
+
else if (chr === ']') seenBracket = false;
|
|
570
570
|
buffer += chr;
|
|
571
571
|
} break;
|
|
572
572
|
|
|
@@ -574,11 +574,11 @@ URLState.prototype = {
|
|
|
574
574
|
if (exec(DIGIT, chr)) {
|
|
575
575
|
buffer += chr;
|
|
576
576
|
} else if (
|
|
577
|
-
chr
|
|
578
|
-
(chr
|
|
577
|
+
chr === EOF || chr === '/' || chr === '?' || chr === '#' ||
|
|
578
|
+
(chr === '\\' && url.isSpecial()) ||
|
|
579
579
|
stateOverride
|
|
580
580
|
) {
|
|
581
|
-
if (buffer
|
|
581
|
+
if (buffer !== '') {
|
|
582
582
|
var port = parseInt(buffer, 10);
|
|
583
583
|
if (port > 0xFFFF) return INVALID_PORT;
|
|
584
584
|
url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port;
|
|
@@ -592,31 +592,35 @@ URLState.prototype = {
|
|
|
592
592
|
|
|
593
593
|
case FILE:
|
|
594
594
|
url.scheme = 'file';
|
|
595
|
-
if (chr
|
|
596
|
-
else if (base && base.scheme
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
url.path = arraySlice(base.path);
|
|
600
|
-
url.query = base.query;
|
|
601
|
-
} else if (chr == '?') {
|
|
602
|
-
url.host = base.host;
|
|
603
|
-
url.path = arraySlice(base.path);
|
|
604
|
-
url.query = '';
|
|
605
|
-
state = QUERY;
|
|
606
|
-
} else if (chr == '#') {
|
|
607
|
-
url.host = base.host;
|
|
608
|
-
url.path = arraySlice(base.path);
|
|
609
|
-
url.query = base.query;
|
|
610
|
-
url.fragment = '';
|
|
611
|
-
state = FRAGMENT;
|
|
612
|
-
} else {
|
|
613
|
-
if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
|
|
595
|
+
if (chr === '/' || chr === '\\') state = FILE_SLASH;
|
|
596
|
+
else if (base && base.scheme === 'file') {
|
|
597
|
+
switch (chr) {
|
|
598
|
+
case EOF:
|
|
614
599
|
url.host = base.host;
|
|
615
600
|
url.path = arraySlice(base.path);
|
|
616
|
-
url.
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
601
|
+
url.query = base.query;
|
|
602
|
+
break;
|
|
603
|
+
case '?':
|
|
604
|
+
url.host = base.host;
|
|
605
|
+
url.path = arraySlice(base.path);
|
|
606
|
+
url.query = '';
|
|
607
|
+
state = QUERY;
|
|
608
|
+
break;
|
|
609
|
+
case '#':
|
|
610
|
+
url.host = base.host;
|
|
611
|
+
url.path = arraySlice(base.path);
|
|
612
|
+
url.query = base.query;
|
|
613
|
+
url.fragment = '';
|
|
614
|
+
state = FRAGMENT;
|
|
615
|
+
break;
|
|
616
|
+
default:
|
|
617
|
+
if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
|
|
618
|
+
url.host = base.host;
|
|
619
|
+
url.path = arraySlice(base.path);
|
|
620
|
+
url.shortenPath();
|
|
621
|
+
}
|
|
622
|
+
state = PATH;
|
|
623
|
+
continue;
|
|
620
624
|
}
|
|
621
625
|
} else {
|
|
622
626
|
state = PATH;
|
|
@@ -624,11 +628,11 @@ URLState.prototype = {
|
|
|
624
628
|
} break;
|
|
625
629
|
|
|
626
630
|
case FILE_SLASH:
|
|
627
|
-
if (chr
|
|
631
|
+
if (chr === '/' || chr === '\\') {
|
|
628
632
|
state = FILE_HOST;
|
|
629
633
|
break;
|
|
630
634
|
}
|
|
631
|
-
if (base && base.scheme
|
|
635
|
+
if (base && base.scheme === 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
|
|
632
636
|
if (isWindowsDriveLetter(base.path[0], true)) push(url.path, base.path[0]);
|
|
633
637
|
else url.host = base.host;
|
|
634
638
|
}
|
|
@@ -636,17 +640,17 @@ URLState.prototype = {
|
|
|
636
640
|
continue;
|
|
637
641
|
|
|
638
642
|
case FILE_HOST:
|
|
639
|
-
if (chr
|
|
643
|
+
if (chr === EOF || chr === '/' || chr === '\\' || chr === '?' || chr === '#') {
|
|
640
644
|
if (!stateOverride && isWindowsDriveLetter(buffer)) {
|
|
641
645
|
state = PATH;
|
|
642
|
-
} else if (buffer
|
|
646
|
+
} else if (buffer === '') {
|
|
643
647
|
url.host = '';
|
|
644
648
|
if (stateOverride) return;
|
|
645
649
|
state = PATH_START;
|
|
646
650
|
} else {
|
|
647
651
|
failure = url.parseHost(buffer);
|
|
648
652
|
if (failure) return failure;
|
|
649
|
-
if (url.host
|
|
653
|
+
if (url.host === 'localhost') url.host = '';
|
|
650
654
|
if (stateOverride) return;
|
|
651
655
|
buffer = '';
|
|
652
656
|
state = PATH_START;
|
|
@@ -657,50 +661,50 @@ URLState.prototype = {
|
|
|
657
661
|
case PATH_START:
|
|
658
662
|
if (url.isSpecial()) {
|
|
659
663
|
state = PATH;
|
|
660
|
-
if (chr
|
|
661
|
-
} else if (!stateOverride && chr
|
|
664
|
+
if (chr !== '/' && chr !== '\\') continue;
|
|
665
|
+
} else if (!stateOverride && chr === '?') {
|
|
662
666
|
url.query = '';
|
|
663
667
|
state = QUERY;
|
|
664
|
-
} else if (!stateOverride && chr
|
|
668
|
+
} else if (!stateOverride && chr === '#') {
|
|
665
669
|
url.fragment = '';
|
|
666
670
|
state = FRAGMENT;
|
|
667
|
-
} else if (chr
|
|
671
|
+
} else if (chr !== EOF) {
|
|
668
672
|
state = PATH;
|
|
669
|
-
if (chr
|
|
673
|
+
if (chr !== '/') continue;
|
|
670
674
|
} break;
|
|
671
675
|
|
|
672
676
|
case PATH:
|
|
673
677
|
if (
|
|
674
|
-
chr
|
|
675
|
-
(chr
|
|
676
|
-
(!stateOverride && (chr
|
|
678
|
+
chr === EOF || chr === '/' ||
|
|
679
|
+
(chr === '\\' && url.isSpecial()) ||
|
|
680
|
+
(!stateOverride && (chr === '?' || chr === '#'))
|
|
677
681
|
) {
|
|
678
682
|
if (isDoubleDot(buffer)) {
|
|
679
683
|
url.shortenPath();
|
|
680
|
-
if (chr
|
|
684
|
+
if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
|
|
681
685
|
push(url.path, '');
|
|
682
686
|
}
|
|
683
687
|
} else if (isSingleDot(buffer)) {
|
|
684
|
-
if (chr
|
|
688
|
+
if (chr !== '/' && !(chr === '\\' && url.isSpecial())) {
|
|
685
689
|
push(url.path, '');
|
|
686
690
|
}
|
|
687
691
|
} else {
|
|
688
|
-
if (url.scheme
|
|
692
|
+
if (url.scheme === 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
|
|
689
693
|
if (url.host) url.host = '';
|
|
690
694
|
buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
|
|
691
695
|
}
|
|
692
696
|
push(url.path, buffer);
|
|
693
697
|
}
|
|
694
698
|
buffer = '';
|
|
695
|
-
if (url.scheme
|
|
699
|
+
if (url.scheme === 'file' && (chr === EOF || chr === '?' || chr === '#')) {
|
|
696
700
|
while (url.path.length > 1 && url.path[0] === '') {
|
|
697
701
|
shift(url.path);
|
|
698
702
|
}
|
|
699
703
|
}
|
|
700
|
-
if (chr
|
|
704
|
+
if (chr === '?') {
|
|
701
705
|
url.query = '';
|
|
702
706
|
state = QUERY;
|
|
703
|
-
} else if (chr
|
|
707
|
+
} else if (chr === '#') {
|
|
704
708
|
url.fragment = '';
|
|
705
709
|
state = FRAGMENT;
|
|
706
710
|
}
|
|
@@ -709,28 +713,28 @@ URLState.prototype = {
|
|
|
709
713
|
} break;
|
|
710
714
|
|
|
711
715
|
case CANNOT_BE_A_BASE_URL_PATH:
|
|
712
|
-
if (chr
|
|
716
|
+
if (chr === '?') {
|
|
713
717
|
url.query = '';
|
|
714
718
|
state = QUERY;
|
|
715
|
-
} else if (chr
|
|
719
|
+
} else if (chr === '#') {
|
|
716
720
|
url.fragment = '';
|
|
717
721
|
state = FRAGMENT;
|
|
718
|
-
} else if (chr
|
|
722
|
+
} else if (chr !== EOF) {
|
|
719
723
|
url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
|
|
720
724
|
} break;
|
|
721
725
|
|
|
722
726
|
case QUERY:
|
|
723
|
-
if (!stateOverride && chr
|
|
727
|
+
if (!stateOverride && chr === '#') {
|
|
724
728
|
url.fragment = '';
|
|
725
729
|
state = FRAGMENT;
|
|
726
|
-
} else if (chr
|
|
727
|
-
if (chr
|
|
728
|
-
else if (chr
|
|
730
|
+
} else if (chr !== EOF) {
|
|
731
|
+
if (chr === "'" && url.isSpecial()) url.query += '%27';
|
|
732
|
+
else if (chr === '#') url.query += '%23';
|
|
729
733
|
else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
|
|
730
734
|
} break;
|
|
731
735
|
|
|
732
736
|
case FRAGMENT:
|
|
733
|
-
if (chr
|
|
737
|
+
if (chr !== EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
|
|
734
738
|
break;
|
|
735
739
|
}
|
|
736
740
|
|
|
@@ -740,8 +744,8 @@ URLState.prototype = {
|
|
|
740
744
|
// https://url.spec.whatwg.org/#host-parsing
|
|
741
745
|
parseHost: function (input) {
|
|
742
746
|
var result, codePoints, index;
|
|
743
|
-
if (charAt(input, 0)
|
|
744
|
-
if (charAt(input, input.length - 1)
|
|
747
|
+
if (charAt(input, 0) === '[') {
|
|
748
|
+
if (charAt(input, input.length - 1) !== ']') return INVALID_HOST;
|
|
745
749
|
result = parseIPv6(stringSlice(input, 1, -1));
|
|
746
750
|
if (!result) return INVALID_HOST;
|
|
747
751
|
this.host = result;
|
|
@@ -764,11 +768,11 @@ URLState.prototype = {
|
|
|
764
768
|
},
|
|
765
769
|
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
|
766
770
|
cannotHaveUsernamePasswordPort: function () {
|
|
767
|
-
return !this.host || this.cannotBeABaseURL || this.scheme
|
|
771
|
+
return !this.host || this.cannotBeABaseURL || this.scheme === 'file';
|
|
768
772
|
},
|
|
769
773
|
// https://url.spec.whatwg.org/#include-credentials
|
|
770
774
|
includesCredentials: function () {
|
|
771
|
-
return this.username
|
|
775
|
+
return this.username !== '' || this.password !== '';
|
|
772
776
|
},
|
|
773
777
|
// https://url.spec.whatwg.org/#is-special
|
|
774
778
|
isSpecial: function () {
|
|
@@ -778,7 +782,7 @@ URLState.prototype = {
|
|
|
778
782
|
shortenPath: function () {
|
|
779
783
|
var path = this.path;
|
|
780
784
|
var pathSize = path.length;
|
|
781
|
-
if (pathSize && (this.scheme
|
|
785
|
+
if (pathSize && (this.scheme !== 'file' || pathSize !== 1 || !isWindowsDriveLetter(path[0], true))) {
|
|
782
786
|
path.length--;
|
|
783
787
|
}
|
|
784
788
|
},
|
|
@@ -801,7 +805,7 @@ URLState.prototype = {
|
|
|
801
805
|
}
|
|
802
806
|
output += serializeHost(host);
|
|
803
807
|
if (port !== null) output += ':' + port;
|
|
804
|
-
} else if (scheme
|
|
808
|
+
} else if (scheme === 'file') output += '//';
|
|
805
809
|
output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
|
|
806
810
|
if (query !== null) output += '?' + query;
|
|
807
811
|
if (fragment !== null) output += '#' + fragment;
|
|
@@ -817,12 +821,12 @@ URLState.prototype = {
|
|
|
817
821
|
getOrigin: function () {
|
|
818
822
|
var scheme = this.scheme;
|
|
819
823
|
var port = this.port;
|
|
820
|
-
if (scheme
|
|
824
|
+
if (scheme === 'blob') try {
|
|
821
825
|
return new URLConstructor(scheme.path[0]).origin;
|
|
822
826
|
} catch (error) {
|
|
823
827
|
return 'null';
|
|
824
828
|
}
|
|
825
|
-
if (scheme
|
|
829
|
+
if (scheme === 'file' || !this.isSpecial()) return 'null';
|
|
826
830
|
return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
|
|
827
831
|
},
|
|
828
832
|
// https://url.spec.whatwg.org/#dom-url-protocol
|
|
@@ -885,7 +889,7 @@ URLState.prototype = {
|
|
|
885
889
|
setPort: function (port) {
|
|
886
890
|
if (this.cannotHaveUsernamePasswordPort()) return;
|
|
887
891
|
port = $toString(port);
|
|
888
|
-
if (port
|
|
892
|
+
if (port === '') this.port = null;
|
|
889
893
|
else this.parse(port, PORT);
|
|
890
894
|
},
|
|
891
895
|
// https://url.spec.whatwg.org/#dom-url-pathname
|
|
@@ -905,10 +909,10 @@ URLState.prototype = {
|
|
|
905
909
|
},
|
|
906
910
|
setSearch: function (search) {
|
|
907
911
|
search = $toString(search);
|
|
908
|
-
if (search
|
|
912
|
+
if (search === '') {
|
|
909
913
|
this.query = null;
|
|
910
914
|
} else {
|
|
911
|
-
if (
|
|
915
|
+
if (charAt(search, 0) === '?') search = stringSlice(search, 1);
|
|
912
916
|
this.query = '';
|
|
913
917
|
this.parse(search, QUERY);
|
|
914
918
|
}
|
|
@@ -925,11 +929,11 @@ URLState.prototype = {
|
|
|
925
929
|
},
|
|
926
930
|
setHash: function (hash) {
|
|
927
931
|
hash = $toString(hash);
|
|
928
|
-
if (hash
|
|
932
|
+
if (hash === '') {
|
|
929
933
|
this.fragment = null;
|
|
930
934
|
return;
|
|
931
935
|
}
|
|
932
|
-
if (
|
|
936
|
+
if (charAt(hash, 0) === '#') hash = stringSlice(hash, 1);
|
|
933
937
|
this.fragment = '';
|
|
934
938
|
this.parse(hash, FRAGMENT);
|
|
935
939
|
},
|
package/package.json
CHANGED