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
+2 -3
View File
@@ -77,10 +77,9 @@ function getTextClass() {
return "text-xl";
}
onBeforeMount(async () => {
await factory.value.init();
onBeforeMount(() => {
factory.value.init();
newDomain();
state.value = State.Ready;
});
onMounted(() => {
setTimeout(() => {
File diff suppressed because it is too large Load Diff
+2598
View File
File diff suppressed because it is too large Load Diff
+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}`;
-26
View File
@@ -1,26 +0,0 @@
import raw_blacklist from "@/data/blacklist.txt";
const BLACKLIST = raw_blacklist.split("\n");
export async function getTLDList(): Promise<string[]> {
const response = await fetch(
"https://cors.klemek.fr/https://data.iana.org/TLD/tlds-alpha-by-domain.txt",
);
const content = await response.text();
const tldList: string[] = [];
content.split("\n").forEach((line) => {
line = line.trim().toLowerCase();
if (
line.length &&
!line.startsWith("//") &&
!line.startsWith("*") &&
!line.startsWith("#") &&
!line.startsWith("xn--") &&
line.replace(/[^\x20-\x7F]/g, "") === line &&
!BLACKLIST.includes(line)
) {
tldList.push(line);
}
});
return tldList;
}