summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/punycode2/to-ascii.js
blob: a56a332c0662c3bac0c625b39ca939cb7eb29e2c (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
'use strict';

var mapDomain = require('./lib/map-domain')
  , encode    = require('./encode')

  , regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars

/**
	* Converts a Unicode string representing a domain name or an email address to
	* Punycode. Only the non-ASCII parts of the domain name will be converted,
	* i.e. it doesn't matter if you call it with a domain that's already in
	* ASCII.
	* @memberOf punycode
	* @param {String} input The domain name or email address to convert, as a
	* Unicode string.
	* @returns {String} The Punycode representation of the given domain name or
	* email address.
*/
module.exports = function (input) {
	return mapDomain(input, function (string) {
		return regexNonASCII.test(string)
			? 'xn--' + encode(string)
			: string;
	});
};