fix: fixed list of tlds
Lint / Oxlint (push) Successful in 48s
Lint / TypeScript (push) Successful in 52s
Lint / ESLint (push) Successful in 56s
Deploy / Build (push) Successful in 1m14s
Deploy / Deploy to Stapler (push) Successful in 5m25s

This commit is contained in:
2026-06-16 11:02:28 +02:00
parent 2753bc2204
commit a18b321787
5 changed files with 2605 additions and 1326 deletions
+5 -11
View File
@@ -1,22 +1,16 @@
import { getTLDList } from "./tld";
import rawTldList from "@/data/tld.txt?raw";
import englishWords from "@/data/english.txt?raw";
import frenchWords from "@/data/french.txt?raw";
import { randomElement, shuffled } from "./random";
const TLD_LIST: string[] = rawTldList.trim().split("\n");
export class DomainFactory {
tldList: string[] = [];
error: string | null = null;
words: Record<string, string[]> = {};
generated: string[] = [];
async init() {
try {
this.tldList = await getTLDList();
} catch (e) {
this.error = "Could not load TLD list";
throw e;
}
init() {
this.words.french = this.initWords(frenchWords);
this.words.english = this.initWords(englishWords);
}
@@ -48,7 +42,7 @@ export class DomainFactory {
randomDomain(lang: string): string | null {
const word = this.randomWord(lang);
for (const tld of shuffled(this.tldList.slice())) {
for (const tld of shuffled(TLD_LIST.slice())) {
const tldEscaped: string = tld.replace(".", "");
if (word.endsWith(tldEscaped) && word.length > tldEscaped.length + 2) {
const domain = `${word.substring(0, word.length - tldEscaped.length)}.${tld}`;