diff options
Diffstat (limited to 'bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js')
-rw-r--r-- | bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js b/bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js new file mode 100644 index 00000000..933fb4a9 --- /dev/null +++ b/bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js @@ -0,0 +1,29 @@ +'use strict'; + +var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators + +/** + * 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 {Array} A new string of characters returned by the callback + * function. +*/ +module.exports = function (string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '.'); + var labels = string.split('.'); + var encoded = labels.map(fn).join('.'); + return result + encoded; +}; |