UNPKG

punycode2

Version:

Modular version of punycode package

23 lines (20 loc) 762 B
"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; }); };