update lại thư mục cấu trúc mới của server nodejs và python

This commit is contained in:
Victor Phan
2026-07-21 09:13:52 +07:00
parent 7625bdd37b
commit 58b1dcd170
1555 changed files with 0 additions and 0 deletions
+666
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+67
View File
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = suffixLookup;
const tldts_core_1 = require("tldts-core");
const trie_1 = require("./data/trie");
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
function suffixLookup(hostname, options, out) {
var _a;
if ((0, tldts_core_1.fastPathLookup)(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, trie_1.exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, trie_1.rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=suffix-trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"suffix-trie.js","sourceRoot":"","sources":["../../../src/suffix-trie.ts"],"names":[],"mappings":";;AA0DA,+BAmDC;AA7GD,2CAIoB;AACpB,sCAAuD;AAcvD;;GAEG;AACH,SAAS,YAAY,CACnB,KAAe,EACf,IAAW,EACX,KAAa,EACb,WAAmB;IAEnB,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG;gBACP,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,4BAAoB;gBACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8BAAsB;aACzC,CAAC;QACJ,CAAC;QAED,8BAA8B;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM;QACR,CAAC;QAED,MAAM,IAAI,GAA+B,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAE,CAAC;YAC9D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CA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