Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function domainToASCII(domain, beStrict = false) {
const result = tr46.toASCII(domain, {
checkBidi: true,
checkHyphens: false,
checkJoiners: true,
useSTD3ASCIIRules: beStrict,
verifyDNSLength: beStrict
});
if (result === null) {
return failure;
}
return result;
}
function domainToASCII(domain, beStrict = false) {
const result = tr46.toASCII(domain, {
checkBidi: true,
checkHyphens: false,
checkJoiners: true,
useSTD3ASCIIRules: beStrict,
verifyDNSLength: beStrict
});
if (result === null) {
return failure;
}
return result;
}
function domainToASCII(domain, beStrict = false) {
const result = tr46.toASCII(domain, {
checkBidi: true,
checkHyphens: false,
checkJoiners: true,
useSTD3ASCIIRules: beStrict,
verifyDNSLength: beStrict
});
if (result === null) {
return failure;
}
return result;
}
function domainToASCII(domain, beStrict = false) {
const result = tr46.toASCII(domain, {
checkBidi: true,
checkHyphens: false,
checkJoiners: true,
useSTD3ASCIIRules: beStrict,
verifyDNSLength: beStrict
});
if (result === null) {
return failure;
}
return result;
}
function parseHost(input, isSpecialArg) {
if (input[0] === "[") {
if (input[input.length - 1] !== "]") {
return failure;
}
return parseIPv6(input.substring(1, input.length - 1));
}
if (!isSpecialArg) {
return parseOpaqueHost(input);
}
const domain = utf8PercentDecode(input);
const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false);
if (asciiDomain === null) {
return failure;
}
if (containsForbiddenHostCodePoint(asciiDomain)) {
return failure;
}
const ipv4Host = parseIPv4(asciiDomain);
if (typeof ipv4Host === "number" || ipv4Host === failure) {
return ipv4Host;
}
return asciiDomain;
}
function parseHost(input, isSpecialArg) {
if (input[0] === "[") {
if (input[input.length - 1] !== "]") {
return failure;
}
return parseIPv6(input.substring(1, input.length - 1));
}
if (!isSpecialArg) {
return parseOpaqueHost(input);
}
const domain = utf8PercentDecode(input);
const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false);
if (asciiDomain === null) {
return failure;
}
if (containsForbiddenHostCodePoint(asciiDomain)) {
return failure;
}
const ipv4Host = parseIPv4(asciiDomain);
if (typeof ipv4Host === "number" || ipv4Host === failure) {
return ipv4Host;
}
return asciiDomain;
}
function serializeOrigin(tuple) {
if (tuple.scheme === undefined || tuple.host === undefined || tuple.port === undefined) {
return "null";
}
let result = tuple.scheme + "://";
result += tr46.toUnicode(tuple.host, false).domain;
if (tuple.port !== null) {
result += ":" + tuple.port;
}
return result;
}
function serializeOrigin(tuple) {
if (tuple.scheme === undefined || tuple.host === undefined || tuple.port === undefined) {
return "null";
}
let result = tuple.scheme + "://";
result += tr46.toUnicode(tuple.host, false).domain;
if (tuple.port !== null) {
result += ":" + tuple.port;
}
return result;
}