rittenhop-ghost/versions/5.94.2/node_modules/punycode2/to-unicode.js

23 lines
762 B
JavaScript

"use strict";
var mapDomain = require("./lib/map-domain")
, decode = require("./decode")
, regexPunycode = /^xn--/;
/**
* Converts a Punycode string representing a domain name or an email address
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
* it doesn't matter if you call it on a string that has already been
* converted to Unicode.
* @memberOf punycode
* @param {String} input The Punycoded domain name or email address to
* convert to Unicode.
* @returns {String} The Unicode representation of the given Punycode
* string.
*/
module.exports = function (input) {
return mapDomain(input, function (string) {
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
});
};