How to use the punycode.toUnicode function in punycode

To help you get started, we’ve selected a few punycode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rockstat / web-sdk / src / functions / pageSource.js View on Github external
source.refHash = simpleHash(page.ref);

  // Direct with marks -> campaign
  // Direct with fbclid -> facebooj social
  if (ref === '') {
    if (has_utm || has_os || has_gclid || has_yclid) {
      source.type = SESSION_CAMPAIGN;
    }
    if(has_fbclid){
      source.type = SESSION_SOCIAL
      source.engine = ENGINE_FACEBOOK
    }
    return source;
  }

  source.refhost = punycode.toUnicode(removeWww(ref.hostname));

  // Internal
  if (ref && source.refhost === removeWww(page.domain)) {
    log('internal detect', ref, source.refhost, removeWww(page.hostname))
    source.type = source.hasMarks ? SESSION_CAMPAIGN : SESSION_INTERNAL;
    return source;
  }

  // Other types: campaigns, organic, social

  const refDomainParts = source.refhost.split('.').reverse();

  for (let i = 0; i < RULES.length; i++) {
    const rule = RULES[i];
    const ruleDomainParts = rule.domain.split('.').reverse();
    const refDomainPartsClone = refDomainParts.slice();
github sx1989827 / DOClever / node_modules / markdown-it / lib / index.js View on Github external
function normalizeLinkText(url) {
  var parsed = mdurl.parse(url, true);

  if (parsed.hostname) {
    // Encode hostnames in urls like:
    // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
    //
    // We don't encode unknown schemas, because it's likely that we encode
    // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
    //
    if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
      try {
        parsed.hostname = punycode.toUnicode(parsed.hostname);
      } catch (er) { /**/ }
    }
  }

  return mdurl.decode(mdurl.format(parsed));
}

github DiedB / Homey-SolarPanels / node_modules / request / node_modules / tough-cookie / generate-pubsuffix.js View on Github external
}
    } else if (index[partstr]) { // exact match, not exception
      suffixLen = i+1;
    }

    suffix = '.'+partstr;
  }

  if (index['*'+suffix]) { // *.domain exists (e.g. *.kyoto.jp for domain='kyoto.jp');
    return null;
  }

  suffixLen = suffixLen || 1;
  if (parts.length > suffixLen) {
    var publicSuffix = parts.slice(0,suffixLen+1).reverse().join('.');
    return converted ? punycode.toUnicode(publicSuffix) : publicSuffix;
  }

  return null;
}
github christianvoigt / argdown / packages / argdown-parser / lib / src / utils.js View on Github external
function normalizeLinkText(url) {
  var parsed = mdurl.parse(url, true);

  if (parsed.hostname) {
    // Encode hostnames in urls like:
    // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
    //
    // We don't encode unknown schemas, because it's likely that we encode
    // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
    //
    if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
      try {
        parsed.hostname = punycode.toUnicode(parsed.hostname);
      } catch (er) {/**/}
    }
  }

  return mdurl.decode(mdurl.format(parsed));
}
github alan-ai / alan-sdk-reactnative / testtools / node_modules / uri-js / dist / esnext / uri.js View on Github external
const uriTokens = [];
    //find scheme handler
    const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
    //perform scheme specific serialization
    if (schemeHandler && schemeHandler.serialize)
        schemeHandler.serialize(components, options);
    if (components.host) {
        //if host component is an IPv6 address
        if (protocol.IPV6ADDRESS.test(components.host)) {
            //TODO: normalize IPv6 address as per RFC 5952
        }
        //if host component is a domain name
        else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {
            //convert IDN via punycode
            try {
                components.host = (!options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host));
            }
            catch (e) {
                components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
            }
        }
    }
    //normalize encoding
    _normalizeComponentEncoding(components, protocol);
    if (options.reference !== "suffix" && components.scheme) {
        uriTokens.push(components.scheme);
        uriTokens.push(":");
    }
    const authority = _recomposeAuthority(components, options);
    if (authority !== undefined) {
        if (options.reference !== "suffix") {
            uriTokens.push("//");
github garycourt / uri-js / dist / esnext / uri.js View on Github external
const uriTokens = [];
    //find scheme handler
    const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
    //perform scheme specific serialization
    if (schemeHandler && schemeHandler.serialize)
        schemeHandler.serialize(components, options);
    if (components.host) {
        //if host component is an IPv6 address
        if (protocol.IPV6ADDRESS.test(components.host)) {
            //TODO: normalize IPv6 address as per RFC 5952
        }
        //if host component is a domain name
        else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {
            //convert IDN via punycode
            try {
                components.host = (!options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host));
            }
            catch (e) {
                components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
            }
        }
    }
    //normalize encoding
    _normalizeComponentEncoding(components, protocol);
    if (options.reference !== "suffix" && components.scheme) {
        uriTokens.push(components.scheme);
        uriTokens.push(":");
    }
    const authority = _recomposeAuthority(components, options);
    if (authority !== undefined) {
        if (options.reference !== "suffix") {
            uriTokens.push("//");
github pmq20 / node-packer / node8 / benchmark / misc / punycode.js View on Github external
function usingPunycode(val) {
  punycode.toUnicode(punycode.toASCII(val));
}
github kazu69 / domain-info / index.js View on Github external
function decodePuny(ascii) {
    return punycode.toUnicode(ascii);
}
github MyEtherWallet / MyEtherWallet / src / builds / mewcx / cxHelpers / helpers.js View on Github external
const parseUrl = url => {
  try {
    return punycode.toUnicode(url);
  } catch (e) {
    return url;
  }
};
github ovh / manager / packages / manager / modules / emailpro / src / emailpro.service.js View on Github external
availableDomains: data.options.map((domain) => ({
          name: domain,
          displayName: punycode.toUnicode(domain),
          formattedName: punycode.toUnicode(domain),
        })),
        availableJoinRestrictions: data.models[

punycode

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis