fix: better whois and smaller tld list
This commit is contained in:
+6
-5
@@ -2,7 +2,6 @@ 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[] = [];
|
||||
@@ -10,9 +9,9 @@ export class DomainFactory {
|
||||
words: Record<string, string[]> = {};
|
||||
generated: string[] = [];
|
||||
|
||||
async init(whois: WhoIs) {
|
||||
async init() {
|
||||
try {
|
||||
this.tldList = await getTLDList(whois);
|
||||
this.tldList = await getTLDList();
|
||||
} catch (e) {
|
||||
this.error = "Could not load TLD list";
|
||||
throw e;
|
||||
@@ -53,8 +52,10 @@ export class DomainFactory {
|
||||
const tldEscaped: string = tld.replace(".", "");
|
||||
if (word.endsWith(tldEscaped) && word.length > tldEscaped.length + 2) {
|
||||
const domain = `${word.substring(0, word.length - tldEscaped.length)}.${tld}`;
|
||||
this.generated.push(domain);
|
||||
return domain;
|
||||
if (!domain.includes("-.")) {
|
||||
this.generated.push(domain);
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user