blob: fe919dec8d0e58b04bef1016b2eb0b28dc817c87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
export default function (hostname, options, out) {
// Fast path for very popular suffixes; this allows to by-pass lookup
// completely as well as any extra allocation or string manipulation.
if (options.allowPrivateDomains === false && hostname.length > 3) {
var last = hostname.length - 1;
var c3 = hostname.charCodeAt(last);
var c2 = hostname.charCodeAt(last - 1);
var c1 = hostname.charCodeAt(last - 2);
var c0 = hostname.charCodeAt(last - 3);
if (c3 === 109 /* 'm' */ &&
c2 === 111 /* 'o' */ &&
c1 === 99 /* 'c' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'com';
return true;
}
else if (c3 === 103 /* 'g' */ &&
c2 === 114 /* 'r' */ &&
c1 === 111 /* 'o' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'org';
return true;
}
else if (c3 === 117 /* 'u' */ &&
c2 === 100 /* 'd' */ &&
c1 === 101 /* 'e' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'edu';
return true;
}
else if (c3 === 118 /* 'v' */ &&
c2 === 111 /* 'o' */ &&
c1 === 103 /* 'g' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'gov';
return true;
}
else if (c3 === 116 /* 't' */ &&
c2 === 101 /* 'e' */ &&
c1 === 110 /* 'n' */ &&
c0 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'net';
return true;
}
else if (c3 === 101 /* 'e' */ &&
c2 === 100 /* 'd' */ &&
c1 === 46 /* '.' */) {
out.isIcann = true;
out.isPrivate = false;
out.publicSuffix = 'de';
return true;
}
}
return false;
}
//# sourceMappingURL=fast-path.js.map
|