feat: let's goooo
Lint / Oxlint (push) Successful in 48s
Deploy / Build (push) Failing after 51s
Lint / ESLint (push) Successful in 57s
Lint / TypeScript (push) Successful in 57s

This commit is contained in:
2026-06-15 19:51:43 +02:00
parent 9d1119b9ed
commit f7dd54f877
12 changed files with 293 additions and 371 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ import { getTLDList } from "./tld";
import englishWords from "@/data/english.txt?raw";
import frenchWords from "@/data/french.txt?raw";
import { randomElement, shuffled } from "./random";
import type { WhoIs } from "./whois";
export class DomainFactory {
tldList: string[] = [];
@@ -9,9 +10,9 @@ export class DomainFactory {
words: Record<string, string[]> = {};
generated: string[] = [];
async init() {
async init(whois: WhoIs) {
try {
this.tldList = await getTLDList();
this.tldList = await getTLDList(whois);
} catch (e) {
this.error = "Could not load TLD list";
throw e;
+32 -12
View File
@@ -1,20 +1,40 @@
export async function getTLDList(): Promise<string[]> {
import type { WhoIs } from "./whois";
export async function getTLDList(whois: WhoIs): Promise<string[]> {
const response = await fetch(
"https://cors.klemek.fr/https://publicsuffix.org/list/public_suffix_list.dat",
);
const content = await response.text();
const tldList: string[] = [];
content.split("\n").forEach((line) => {
line = line.trim();
if (
line.length &&
!line.startsWith("//") &&
!line.startsWith("*") &&
line.replace(/[^\\x00-\\x7F]/g, "") === line &&
(!line.includes(".") || tldList.every((other) => !line.endsWith(other)))
) {
tldList.push(line);
// @ts-expect-error - not empty string
content
.split("// ===END ICANN DOMAINS===")[0]
.split("\n")
.forEach((line) => {
line = line.trim();
if (
line.length &&
!line.startsWith("//") &&
!line.startsWith("*") &&
line.replace(/[^\x20-\x7F]/g, "") === line
) {
tldList.forEach((other) => {
if (line.endsWith(`.${other}`)) {
tldList.splice(tldList.indexOf(other), 1);
}
});
tldList.push(line);
}
});
return tldList.filter((tld) => {
if (!whois.rdapEndpoints) {
return true;
}
for (const rdap_tld of Object.keys(whois.rdapEndpoints)) {
if (rdap_tld == tld || tld.endsWith(`.${rdap_tld}`)) {
return true;
}
}
return false;
});
return tldList;
}