Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Ahkrin <sebastien48criquet@gmail.com>2020-01-06 05:55:31 +0300
committerMichaƫl Zasso <targos@protonmail.com>2020-10-04 10:40:56 +0300
commitb79829c5f5018eb99ea514ccb8e91b4eabc0f97c (patch)
tree91f15e289299a425757fec02e2b6f4afd2801cc3 /lib/tls.js
parent693cc2c1c3cb61adaff532dea225b03eadf14a9b (diff)
lib: replace String global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Pranshu Srivastava <rexagod@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Diffstat (limited to 'lib/tls.js')
-rw-r--r--lib/tls.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/tls.js b/lib/tls.js
index 2ccbe409c96..a46031ad7da 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -26,6 +26,10 @@ const {
ArrayIsArray,
ObjectDefineProperty,
ObjectFreeze,
+ StringFromCharCode,
+ StringPrototypeCharCodeAt,
+ StringPrototypeReplace,
+ StringPrototypeSplit,
} = primordials;
const {
@@ -137,11 +141,17 @@ function unfqdn(host) {
return host.replace(/[.]$/, '');
}
+// String#toLowerCase() is locale-sensitive so we use
+// a conservative version that only lowercases A-Z.
+function toLowerCase(c) {
+ return StringFromCharCode(32 + StringPrototypeCharCodeAt(c, 0));
+}
+
function splitHost(host) {
- // String#toLowerCase() is locale-sensitive so we use
- // a conservative version that only lowercases A-Z.
- const replacer = (c) => String.fromCharCode(32 + c.charCodeAt(0));
- return unfqdn(host).replace(/[A-Z]/g, replacer).split('.');
+ return StringPrototypeSplit(
+ StringPrototypeReplace(unfqdn(host), /[A-Z]/g, toLowerCase),
+ '.'
+ );
}
function check(hostParts, pattern, wildcards) {