| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0930be6 commit 8a08275
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ const { | |||
| 4 | 4 | DateNow, | |
| 5 | 5 | NumberIsNaN, | |
| 6 | 6 | ObjectDefineProperties, | |
| 7 | + StringPrototypeToWellFormed, | ||
| 7 | 8 | SymbolToStringTag, | |
| 8 | 9 | } = primordials; | |
| 9 | 10 | ||
@@ -15,7 +16,6 @@ const { | |||
| 15 | 16 | customInspectSymbol: kInspect, | |
| 16 | 17 | kEnumerableProperty, | |
| 17 | 18 | kEmptyObject, | |
| 18 | - toUSVString, | ||
| 19 | 19 | } = require('internal/util'); | |
| 20 | 20 | ||
| 21 | 21 | const { | |
@@ -55,7 +55,7 @@ class File extends Blob { | |||
| 55 | 55 | lastModified = DateNow(); | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | - this.#name = toUSVString(fileName); | ||
| 58 | + this.#name = StringPrototypeToWellFormed(`${fileName}`); | ||
| 59 | 59 | this.#lastModified = lastModified; | |
| 60 | 60 | } | |
| 61 | 61 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ const { | |||
| 26 | 26 | StringPrototypeIndexOf, | |
| 27 | 27 | StringPrototypeSlice, | |
| 28 | 28 | StringPrototypeStartsWith, | |
| 29 | + StringPrototypeToWellFormed, | ||
| 29 | 30 | Symbol, | |
| 30 | 31 | SymbolIterator, | |
| 31 | 32 | SymbolToStringTag, | |
@@ -42,7 +43,6 @@ const { | |||
| 42 | 43 | const { | |
| 43 | 44 | getConstructorOf, | |
| 44 | 45 | removeColors, | |
| 45 | - toUSVString, | ||
| 46 | 46 | kEnumerableProperty, | |
| 47 | 47 | SideEffectFreeRegExpPrototypeSymbolReplace, | |
| 48 | 48 | } = require('internal/util'); | |
@@ -360,7 +360,11 @@ class URLSearchParams { | |||
| 360 | 360 | throw new ERR_INVALID_TUPLE('Each query pair', '[name, value]'); | |
| 361 | 361 | } | |
| 362 | 362 | // Append (innerSequence[0], innerSequence[1]) to querys list. | |
| 363 | - ArrayPrototypePush(this.#searchParams, toUSVString(pair[0]), toUSVString(pair[1])); | ||
| 363 | + ArrayPrototypePush( | ||
| 364 | + this.#searchParams, | ||
| 365 | + StringPrototypeToWellFormed(`${pair[0]}`), | ||
| 366 | + StringPrototypeToWellFormed(`${pair[1]}`), | ||
| 367 | + ); | ||
| 364 | 368 | } else { | |
| 365 | 369 | if (((typeof pair !== 'object' && typeof pair !== 'function') || | |
| 366 | 370 | typeof pair[SymbolIterator] !== 'function')) { | |
@@ -371,7 +375,7 @@ class URLSearchParams { | |||
| 371 | 375 | ||
| 372 | 376 | for (const element of pair) { | |
| 373 | 377 | length++; | |
| 374 | - ArrayPrototypePush(this.#searchParams, toUSVString(element)); | ||
| 378 | + ArrayPrototypePush(this.#searchParams, StringPrototypeToWellFormed(`${element}`)); | ||
| 375 | 379 | } | |
| 376 | 380 | ||
| 377 | 381 | // If innerSequence's size is not 2, then throw a TypeError. | |
@@ -389,8 +393,8 @@ class URLSearchParams { | |||
| 389 | 393 | const key = keys[i]; | |
| 390 | 394 | const desc = ReflectGetOwnPropertyDescriptor(init, key); | |
| 391 | 395 | if (desc !== undefined && desc.enumerable) { | |
| 392 | - const typedKey = toUSVString(key); | ||
| 393 | - const typedValue = toUSVString(init[key]); | ||
| 396 | + const typedKey = StringPrototypeToWellFormed(key); | ||
| 397 | + const typedValue = StringPrototypeToWellFormed(`${init[key]}`); | ||
| 394 | 398 | ||
| 395 | 399 | // Two different keys may become the same USVString after normalization. | |
| 396 | 400 | // In that case, we retain the later one. Refer to WPT. | |
@@ -407,7 +411,7 @@ class URLSearchParams { | |||
| 407 | 411 | } | |
| 408 | 412 | } else { | |
| 409 | 413 | // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams | |
| 410 | - init = toUSVString(init); | ||
| 414 | + init = StringPrototypeToWellFormed(`${init}`); | ||
| 411 | 415 | this.#searchParams = init ? parseParams(init) : []; | |
| 412 | 416 | } | |
| 413 | 417 | } | |
@@ -462,8 +466,8 @@ class URLSearchParams { | |||
| 462 | 466 | throw new ERR_MISSING_ARGS('name', 'value'); | |
| 463 | 467 | } | |
| 464 | 468 | ||
| 465 | - name = toUSVString(name); | ||
| 466 | - value = toUSVString(value); | ||
| 469 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 470 | + value = StringPrototypeToWellFormed(`${value}`); | ||
| 467 | 471 | ArrayPrototypePush(this.#searchParams, name, value); | |
| 468 | 472 | if (this.#context) { | |
| 469 | 473 | this.#context.search = this.toString(); | |
@@ -479,10 +483,10 @@ class URLSearchParams { | |||
| 479 | 483 | } | |
| 480 | 484 | ||
| 481 | 485 | const list = this.#searchParams; | |
| 482 | - name = toUSVString(name); | ||
| 486 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 483 | 487 | ||
| 484 | 488 | if (value !== undefined) { | |
| 485 | - value = toUSVString(value); | ||
| 489 | + value = StringPrototypeToWellFormed(`${value}`); | ||
| 486 | 490 | for (let i = 0; i < list.length;) { | |
| 487 | 491 | if (list[i] === name && list[i + 1] === value) { | |
| 488 | 492 | list.splice(i, 2); | |
@@ -513,7 +517,7 @@ class URLSearchParams { | |||
| 513 | 517 | } | |
| 514 | 518 | ||
| 515 | 519 | const list = this.#searchParams; | |
| 516 | - name = toUSVString(name); | ||
| 520 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 517 | 521 | for (let i = 0; i < list.length; i += 2) { | |
| 518 | 522 | if (list[i] === name) { | |
| 519 | 523 | return list[i + 1]; | |
@@ -532,7 +536,7 @@ class URLSearchParams { | |||
| 532 | 536 | ||
| 533 | 537 | const list = this.#searchParams; | |
| 534 | 538 | const values = []; | |
| 535 | - name = toUSVString(name); | ||
| 539 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 536 | 540 | for (let i = 0; i < list.length; i += 2) { | |
| 537 | 541 | if (list[i] === name) { | |
| 538 | 542 | values.push(list[i + 1]); | |
@@ -550,10 +554,10 @@ class URLSearchParams { | |||
| 550 | 554 | } | |
| 551 | 555 | ||
| 552 | 556 | const list = this.#searchParams; | |
| 553 | - name = toUSVString(name); | ||
| 557 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 554 | 558 | ||
| 555 | 559 | if (value !== undefined) { | |
| 556 | - value = toUSVString(value); | ||
| 560 | + value = StringPrototypeToWellFormed(`${value}`); | ||
| 557 | 561 | } | |
| 558 | 562 | ||
| 559 | 563 | for (let i = 0; i < list.length; i += 2) { | |
@@ -576,8 +580,8 @@ class URLSearchParams { | |||
| 576 | 580 | } | |
| 577 | 581 | ||
| 578 | 582 | const list = this.#searchParams; | |
| 579 | - name = toUSVString(name); | ||
| 580 | - value = toUSVString(value); | ||
| 583 | + name = StringPrototypeToWellFormed(`${name}`); | ||
| 584 | + value = StringPrototypeToWellFormed(`${value}`); | ||
| 581 | 585 | ||
| 582 | 586 | // If there are any name-value pairs whose name is `name`, in `list`, set | |
| 583 | 587 | // the value of the first such name-value pair to `value` and remove the | |
@@ -765,7 +769,7 @@ class URL { | |||
| 765 | 769 | throw new ERR_MISSING_ARGS('url'); | |
| 766 | 770 | } | |
| 767 | 771 | ||
| 768 | - // toUSVString is not needed. | ||
| 772 | + // StringPrototypeToWellFormed is not needed. | ||
| 769 | 773 | input = `${input}`; | |
| 770 | 774 | ||
| 771 | 775 | if (base !== undefined) { | |
@@ -998,7 +1002,7 @@ class URL { | |||
| 998 | 1002 | } | |
| 999 | 1003 | ||
| 1000 | 1004 | set search(value) { | |
| 1001 | - const href = bindingUrl.update(this.#context.href, updateActions.kSearch, toUSVString(value)); | ||
| 1005 | + const href = bindingUrl.update(this.#context.href, updateActions.kSearch, StringPrototypeToWellFormed(`${value}`)); | ||
| 1002 | 1006 | if (href) { | |
| 1003 | 1007 | this.#updateContext(href); | |
| 1004 | 1008 | } | |
@@ -1289,15 +1293,15 @@ function domainToASCII(domain) { | |||
| 1289 | 1293 | if (arguments.length < 1) | |
| 1290 | 1294 | throw new ERR_MISSING_ARGS('domain'); | |
| 1291 | 1295 | ||
| 1292 | - // toUSVString is not needed. | ||
| 1296 | + // StringPrototypeToWellFormed is not needed. | ||
| 1293 | 1297 | return bindingUrl.domainToASCII(`${domain}`); | |
| 1294 | 1298 | } | |
| 1295 | 1299 | ||
| 1296 | 1300 | function domainToUnicode(domain) { | |
| 1297 | 1301 | if (arguments.length < 1) | |
| 1298 | 1302 | throw new ERR_MISSING_ARGS('domain'); | |
| 1299 | 1303 | ||
| 1300 | - // toUSVString is not needed. | ||
| 1304 | + // StringPrototypeToWellFormed is not needed. | ||
| 1301 | 1305 | return bindingUrl.domainToUnicode(`${domain}`); | |
| 1302 | 1306 | } | |
| 1303 | 1307 | ||
@@ -1493,7 +1497,6 @@ function getURLOrigin(url) { | |||
| 1493 | 1497 | } | |
| 1494 | 1498 | ||
| 1495 | 1499 | module.exports = { | |
| 1496 | - toUSVString, | ||
| 1497 | 1500 | fileURLToPath, | |
| 1498 | 1501 | pathToFileURL, | |
| 1499 | 1502 | toPathIfFileURL, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,6 @@ const { | |||
| 62 | 62 | decorated_private_symbol, | |
| 63 | 63 | }, | |
| 64 | 64 | sleep: _sleep, | |
| 65 | - toUSVString: _toUSVString, | ||
| 66 | 65 | } = internalBinding('util'); | |
| 67 | 66 | const { isNativeError } = internalBinding('types'); | |
| 68 | 67 | const { getOptionValue } = require('internal/options'); | |
@@ -73,18 +72,6 @@ const experimentalWarnings = new SafeSet(); | |||
| 73 | 72 | ||
| 74 | 73 | const colorRegExp = /\u001b\[\d\d?m/g; // eslint-disable-line no-control-regex | |
| 75 | 74 | ||
| 76 | - const unpairedSurrogateRe = | ||
| 77 | - /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/; | ||
| 78 | - function toUSVString(val) { | ||
| 79 | - const str = `${val}`; | ||
| 80 | - // As of V8 5.5, `str.search()` (and `unpairedSurrogateRe[@@search]()`) are | ||
| 81 | - // slower than `unpairedSurrogateRe.exec()`. | ||
| 82 | - const match = RegExpPrototypeExec(unpairedSurrogateRe, str); | ||
| 83 | - if (!match) | ||
| 84 | - return str; | ||
| 85 | - return _toUSVString(str, match.index); | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | 75 | let uvBinding; | |
| 89 | 76 | ||
| 90 | 77 | function lazyUv() { | |
@@ -910,7 +897,6 @@ module.exports = { | |||
| 910 | 897 | sleep, | |
| 911 | 898 | spliceOne, | |
| 912 | 899 | setupCoverageHooks, | |
| 913 | - toUSVString, | ||
| 914 | 900 | removeColors, | |
| 915 | 901 | ||
| 916 | 902 | // Symbol used to customize promisify conversion | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ const { | |||
| 44 | 44 | ObjectValues, | |
| 45 | 45 | ReflectApply, | |
| 46 | 46 | StringPrototypePadStart, | |
| 47 | + StringPrototypeToWellFormed, | ||
| 47 | 48 | } = primordials; | |
| 48 | 49 | ||
| 49 | 50 | const { | |
@@ -75,7 +76,6 @@ const { | |||
| 75 | 76 | getSystemErrorMap, | |
| 76 | 77 | getSystemErrorName: internalErrorName, | |
| 77 | 78 | promisify, | |
| 78 | - toUSVString, | ||
| 79 | 79 | defineLazyProperties, | |
| 80 | 80 | } = require('internal/util'); | |
| 81 | 81 | ||
@@ -411,7 +411,9 @@ module.exports = { | |||
| 411 | 411 | log, | |
| 412 | 412 | promisify, | |
| 413 | 413 | stripVTControlCharacters, | |
| 414 | - toUSVString, | ||
| 414 | + toUSVString(input) { | ||
| 415 | + return StringPrototypeToWellFormed(`${input}`); | ||
| 416 | + }, | ||
| 415 | 417 | get transferableAbortSignal() { | |
| 416 | 418 | return lazyAbortController().transferableAbortSignal; | |
| 417 | 419 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,9 +37,6 @@ using v8::String; | |||
| 37 | 37 | using v8::Uint32; | |
| 38 | 38 | using v8::Value; | |
| 39 | 39 | ||
| 40 | - // Used in ToUSVString(). | ||
| 41 | - constexpr char16_t kUnicodeReplacementCharacter = 0xFFFD; | ||
| 42 | - | ||
| 43 | 40 | // If a UTF-16 character is a low/trailing surrogate. | |
| 44 | 41 | CHAR_TEST(16, IsUnicodeTrail, (ch & 0xFC00) == 0xDC00) | |
| 45 | 42 | ||
@@ -240,40 +237,6 @@ static uint32_t FastGuessHandleType(Local<Value> receiver, const uint32_t fd) { | |||
| 240 | 237 | ||
| 241 | 238 | CFunction fast_guess_handle_type_(CFunction::Make(FastGuessHandleType)); | |
| 242 | 239 | ||
| 243 | - static void ToUSVString(const FunctionCallbackInfo<Value>& args) { | ||
| 244 | - Environment* env = Environment::GetCurrent(args); | ||
| 245 | - CHECK_GE(args.Length(), 2); | ||
| 246 | - CHECK(args[0]->IsString()); | ||
| 247 | - CHECK(args[1]->IsNumber()); | ||
| 248 | - | ||
| 249 | - TwoByteValue value(env->isolate(), args[0]); | ||
| 250 | - | ||
| 251 | - int64_t start = args[1]->IntegerValue(env->context()).FromJust(); | ||
| 252 | - CHECK_GE(start, 0); | ||
| 253 | - | ||
| 254 | - for (size_t i = start; i < value.length(); i++) { | ||
| 255 | - char16_t c = value[i]; | ||
| 256 | - if (!IsUnicodeSurrogate(c)) { | ||
| 257 | - continue; | ||
| 258 | - } else if (IsUnicodeSurrogateTrail(c) || i == value.length() - 1) { | ||
| 259 | - value[i] = kUnicodeReplacementCharacter; | ||
| 260 | - } else { | ||
| 261 | - char16_t d = value[i + 1]; | ||
| 262 | - if (IsUnicodeTrail(d)) { | ||
| 263 | - i++; | ||
| 264 | - } else { | ||
| 265 | - value[i] = kUnicodeReplacementCharacter; | ||
| 266 | - } | ||
| 267 | - } | ||
| 268 | - } | ||
| 269 | - | ||
| 270 | - args.GetReturnValue().Set( | ||
| 271 | - String::NewFromTwoByte(env->isolate(), | ||
| 272 | - *value, | ||
| 273 | - v8::NewStringType::kNormal, | ||
| 274 | - value.length()).ToLocalChecked()); | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | 240 | void RegisterExternalReferences(ExternalReferenceRegistry* registry) { | |
| 278 | 241 | registry->Register(GetPromiseDetails); | |
| 279 | 242 | registry->Register(GetProxyDetails); | |
@@ -288,7 +251,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) { | |||
| 288 | 251 | registry->Register(GuessHandleType); | |
| 289 | 252 | registry->Register(FastGuessHandleType); | |
| 290 | 253 | registry->Register(fast_guess_handle_type_.GetTypeInfo()); | |
| 291 | - registry->Register(ToUSVString); | ||
| 292 | 254 | } | |
| 293 | 255 | ||
| 294 | 256 | void Initialize(Local<Object> target, | |
@@ -389,8 +351,6 @@ void Initialize(Local<Object> target, | |||
| 389 | 351 | "guessHandleType", | |
| 390 | 352 | GuessHandleType, | |
| 391 | 353 | &fast_guess_handle_type_); | |
| 392 | - | ||
| 393 | - SetMethodNoSideEffect(context, target, "toUSVString", ToUSVString); | ||
| 394 | 354 | } | |
| 395 | 355 | ||
| 396 | 356 | } // namespace util | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,5 +43,4 @@ export interface UtilBinding { | |||
| 43 | 43 | shouldAbortOnUncaughtToggle: [shouldAbort: 0 | 1]; | |
| 44 | 44 | WeakReference: typeof InternalUtilBinding.WeakReference; | |
| 45 | 45 | guessHandleType(fd: number): 'TCP' | 'TTY' | 'UDP' | 'FILE' | 'PIPE' | 'UNKNOWN'; | |
| 46 | - toUSVString(str: string, start: number): string; | ||
| 47 | 46 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -420,6 +420,7 @@ declare namespace primordials { | |||
| 420 | 420 | export const StringPrototypeToLocaleUpperCase: UncurryThis<typeof String.prototype.toLocaleUpperCase> | |
| 421 | 421 | export const StringPrototypeToLowerCase: UncurryThis<typeof String.prototype.toLowerCase> | |
| 422 | 422 | export const StringPrototypeToUpperCase: UncurryThis<typeof String.prototype.toUpperCase> | |
| 423 | + export const StringPrototypeToWellFormed: UncurryThis<typeof String.prototype.toWellFormed> | ||
| 423 | 424 | export const StringPrototypeValueOf: UncurryThis<typeof String.prototype.valueOf> | |
| 424 | 425 | export const StringPrototypeReplaceAll: UncurryThis<typeof String.prototype.replaceAll> | |
| 425 | 426 | export import Symbol = globalThis.Symbol; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments