tldts-core
Advanced tools
Comparing version 5.6.0 to 5.6.1
@@ -256,11 +256,19 @@ 'use strict'; | ||
function isProbablyIpv6(hostname) { | ||
if (hostname.length < 3) { | ||
return false; | ||
} | ||
var start = hostname[0] === '[' ? 1 : 0; | ||
var end = hostname.length; | ||
if (hostname[end - 1] === ']') { | ||
end -= 1; | ||
} | ||
// We only consider the maximum size of a normal IPV6. Note that this will | ||
// fail on so-called "IPv4 mapped IPv6 addresses" but this is a corner-case | ||
// and a proper validation library should be used for these. | ||
if (hostname.length > 39) { | ||
if (end - start > 39) { | ||
return false; | ||
} | ||
var hasColon = false; | ||
for (var i = 0; i < hostname.length; i += 1) { | ||
var code = hostname.charCodeAt(i); | ||
for (; start < end; start += 1) { | ||
var code = hostname.charCodeAt(start); | ||
if (code === 58 /* ':' */) { | ||
@@ -270,4 +278,5 @@ hasColon = true; | ||
else if (((code >= 48 && code <= 57) || // 0-9 | ||
(code >= 97 && code <= 102)) === false // a-f | ||
) { | ||
(code >= 97 && code <= 102) || // a-f | ||
(code >= 65 && code <= 90) // A-F | ||
) === false) { | ||
return false; | ||
@@ -274,0 +283,0 @@ } |
@@ -32,11 +32,19 @@ /** | ||
function isProbablyIpv6(hostname) { | ||
if (hostname.length < 3) { | ||
return false; | ||
} | ||
var start = hostname[0] === '[' ? 1 : 0; | ||
var end = hostname.length; | ||
if (hostname[end - 1] === ']') { | ||
end -= 1; | ||
} | ||
// We only consider the maximum size of a normal IPV6. Note that this will | ||
// fail on so-called "IPv4 mapped IPv6 addresses" but this is a corner-case | ||
// and a proper validation library should be used for these. | ||
if (hostname.length > 39) { | ||
if (end - start > 39) { | ||
return false; | ||
} | ||
var hasColon = false; | ||
for (var i = 0; i < hostname.length; i += 1) { | ||
var code = hostname.charCodeAt(i); | ||
for (; start < end; start += 1) { | ||
var code = hostname.charCodeAt(start); | ||
if (code === 58 /* ':' */) { | ||
@@ -46,4 +54,5 @@ hasColon = true; | ||
else if (((code >= 48 && code <= 57) || // 0-9 | ||
(code >= 97 && code <= 102)) === false // a-f | ||
) { | ||
(code >= 97 && code <= 102) || // a-f | ||
(code >= 65 && code <= 90) // A-F | ||
) === false) { | ||
return false; | ||
@@ -50,0 +59,0 @@ } |
{ | ||
"name": "tldts-core", | ||
"version": "5.6.0", | ||
"version": "5.6.1", | ||
"description": "tldts core primitives (internal module)", | ||
@@ -66,3 +66,3 @@ "author": { | ||
}, | ||
"gitHead": "2a8c96aa9e692d9426b0a85c0db29939f3d58fce" | ||
"gitHead": "f64d9d5c1e8e91aa7bf197d4364f50428e0b45fa" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
184419
1184