summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/punycode2/lib/map-domain.js
blob: 933fb4a9155a382d299c13b2c75124af32f29f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
};