-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: refactor to use more primordials
PR-URL: #36266 Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
9cb53f6
commit b20409e
Showing
4 changed files
with
91 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,27 @@ | |
|
||
const { | ||
ArrayIsArray, | ||
ArrayPrototypePush, | ||
StringPrototypeIndexOf, | ||
StringPrototypeSlice, | ||
StringPrototypeSplit, | ||
ObjectCreate, | ||
} = primordials; | ||
|
||
// Example: | ||
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\[email protected] | ||
function parseCertString(s) { | ||
const out = ObjectCreate(null); | ||
for (const part of s.split('\n')) { | ||
const sepIndex = part.indexOf('='); | ||
for (const part of StringPrototypeSplit(s, '\n')) { | ||
const sepIndex = StringPrototypeIndexOf(part, '='); | ||
if (sepIndex > 0) { | ||
const key = part.slice(0, sepIndex); | ||
const value = part.slice(sepIndex + 1); | ||
const key = StringPrototypeSlice(part, 0, sepIndex); | ||
const value = StringPrototypeSlice(part, sepIndex + 1); | ||
if (key in out) { | ||
if (!ArrayIsArray(out[key])) { | ||
out[key] = [out[key]]; | ||
} | ||
out[key].push(value); | ||
ArrayPrototypePush(out[key], value); | ||
} else { | ||
out[key] = value; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters