Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idna-uts46-hx

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idna-uts46-hx - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

dist/index.d.ts

7

HISTORY.md

@@ -0,1 +1,8 @@

## [6.0.1](https://github.com/centralnicgroup-opensource/rtldev-middleware-idna-uts46/compare/v6.0.0...v6.0.1) (2024-2-23)
### Bug Fixes
* **build:** add missing type definitions ([4a152c8](https://github.com/centralnicgroup-opensource/rtldev-middleware-idna-uts46/commit/4a152c8984f130a252a4cb295d5b07fde874b7a7))
# [6.0.0](https://github.com/centralnicgroup-opensource/rtldev-middleware-idna-uts46/compare/v5.1.2...v6.0.0) (2024-2-22)

@@ -2,0 +9,0 @@

3

package.json
{
"name": "idna-uts46-hx",
"description": "Convert Domain Names correctly from IDN to Punycode and vice-versa and offer TR46 processing.",
"version": "6.0.0",
"version": "6.0.1",
"private": false,
"type": "module",
"main": "dist/index.mjs",
"typings": "dist/index.d.ts",
"license": "MIT",

@@ -9,0 +10,0 @@ "sideEffects": false,

import tr46 from 'tr46';
function getDefaultOptions(domain) {
function getDefaultOptions(domainName) {
return {
transitionalProcessing: !domain.match(
transitionalProcessing: !domainName.match(
/\.(?:be|ca|de|swiss|fr|pm|re|tf|wf|yt)\.?$/,

@@ -11,31 +11,37 @@ ),

function toAscii(domain, opts = {}) {
const pc = tr46.toASCII(domain, { ...getDefaultOptions(domain), ...opts });
function toAscii(domainName, options = {}) {
const pc = tr46.toASCII(domainName, {
...getDefaultOptions(domainName),
...options,
});
if (pc !== null) {
return pc;
}
throw new Error(`Unable to translate ${domain} to ASCII.`);
throw new Error(`Unable to translate ${domainName} to ASCII.`);
}
function toUnicode(domain, opts = {}) {
const idn = tr46.toUnicode(domain, { ...getDefaultOptions(domain), ...opts });
function toUnicode(domainName, options = {}) {
const idn = tr46.toUnicode(domainName, {
...getDefaultOptions(domainName),
...options,
});
if (idn !== null && !idn.error) {
return idn.domain;
}
throw new Error(`Unable to translate ${domain} to Unicode.`);
throw new Error(`Unable to translate ${domainName} to Unicode.`);
}
function convert(domains) {
const isArrayInput = Array.isArray(domains);
function convert(domainNames, options = {}) {
const isArrayInput = Array.isArray(domainNames);
if (!isArrayInput) {
domains = [domains];
domainNames = [domainNames];
}
const results = { IDN: [], PC: [] };
domains.forEach((domain) => {
domainNames.forEach((domainName) => {
try {
results.PC.push(toAscii(domain));
results.IDN.push(toUnicode(domain));
results.PC.push(toAscii(domainName, options));
results.IDN.push(toUnicode(domainName, options));
} catch (e) {
results.PC.push(domain);
results.IDN.push(domain);
results.PC.push(domainName);
results.IDN.push(domainName);
}

@@ -42,0 +48,0 @@ });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc