MCPcopy Index your code
hub / github.com/nodejs/node / mapDomain

Function mapDomain

lib/punycode.js:84–98  ·  view source on GitHub ↗

* A simple `Array#map`-like wrapper to work with domain name strings or email * addresses. * @private * @param {String} domain The domain name or email address. * @param {Function} callback The function that gets called for every * character. * @returns {String} A new string of characters retu

(domain, callback)

Source from the content-addressed store, hash-verified

82 * function.
83 */
84function mapDomain(domain, callback) {
85 const parts = domain.split('@');
86 let result = '';
87 if (parts.length > 1) {
88 // In email addresses, only the domain name should be punycoded. Leave
89 // the local part (i.e. everything up to `@`) intact.
90 result = parts[0] + '@';
91 domain = parts[1];
92 }
93 // Avoid `split(regex)` for IE8 compatibility. See #17.
94 domain = domain.replace(regexSeparators, '\x2E');
95 const labels = domain.split('.');
96 const encoded = map(labels, callback).join('.');
97 return result + encoded;
98}
99
100/**
101 * Creates an array containing the numeric code points of each Unicode

Callers 2

toUnicodeFunction · 0.85
toASCIIFunction · 0.85

Calls 3

mapFunction · 0.70
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…