fix: use fixed tld list
This commit is contained in:
@@ -44,3 +44,45 @@ options:
|
||||
--tld-list-uri TLD_LIST_URI
|
||||
Top Level Domains list (default: https://publicsuffix.org/list/public_suffix_list.dat)
|
||||
```
|
||||
|
||||
# Development
|
||||
|
||||
## Updating `tld.txt`
|
||||
|
||||
Go to [tld-list.com](https://tld-list.com) and open console.
|
||||
|
||||
```js
|
||||
async function getValidTlds() {
|
||||
const delay = (millis) =>
|
||||
new Promise((resolve, reject) => {
|
||||
setTimeout((_) => {
|
||||
resolve();
|
||||
}, millis);
|
||||
});
|
||||
|
||||
const sourceData = await (
|
||||
await fetch("https://tld-list.com/tlds-from-a-z")
|
||||
).text();
|
||||
const regexp = /href="\/tld\/([\w\.]+)"/gm;
|
||||
const outTlds = [];
|
||||
let match;
|
||||
|
||||
while ((match = regexp.exec(sourceData)) !== null) {
|
||||
const tld = match[1];
|
||||
await delay(100);
|
||||
console.log(tld);
|
||||
const resp = await fetch(`https://tld-list.com/tld/${tld}`);
|
||||
if (resp.status === 200) {
|
||||
const content = await resp.text();
|
||||
if (!content.includes("Registrars (0)")) {
|
||||
outTlds.push(tld);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outTlds;
|
||||
}
|
||||
|
||||
const tlds = await getValidTlds();
|
||||
|
||||
console.log(tlds.join(','));
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user