fix: tld-list link with correct extension
Lint / Oxlint (push) Successful in 3m57s
Deploy / Build (push) Successful in 4m14s
Lint / TypeScript (push) Successful in 3m57s
Lint / ESLint (push) Successful in 4m7s
Deploy / Deploy to Stapler (push) Successful in 6m5s

This commit is contained in:
2026-06-26 14:28:22 +02:00
parent e5ab509c29
commit e883073ea7
3 changed files with 16 additions and 5 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ function newDomain() {
<span v-else-if="domain.available" <span v-else-if="domain.available"
>&nbsp;{{ $t("seems") }} >&nbsp;{{ $t("seems") }}
<a <a
:href="`https://tld-list.com/${$i18n.locale}/tld/${domain.name?.split('.')[1]}`" :href="`https://tld-list.com/${$i18n.locale}/tld/${domain.extension}`"
target="_blank" target="_blank"
class="underline" class="underline"
>{{ $t("available") }}</a >{{ $t("available") }}</a
+2 -2
View File
@@ -62,7 +62,7 @@ function checkAvailability() {
function removeExt() { function removeExt() {
if (domain.value) { if (domain.value) {
props.factory.removeExt(domain.value.extension); props.factory.removeExtensions(domain.value.extension);
newDomain(); newDomain();
} }
} }
@@ -108,7 +108,7 @@ watch(i18n.locale, newDomain);
<div v-else-if="state === State.Ready && domain?.available" class="py-6"> <div v-else-if="state === State.Ready && domain?.available" class="py-6">
{{ $t("this_domain") }} {{ $t("seems") }} {{ $t("this_domain") }} {{ $t("seems") }}
<a <a
:href="`https://tld-list.com/${$i18n.locale}/tld/${domain.name?.split('.')[1]}`" :href="`https://tld-list.com/${$i18n.locale}/tld/${domain.extension}`"
target="_blank" target="_blank"
class="underline" class="underline"
>{{ $t("available") }}</a >{{ $t("available") }}</a
+13 -2
View File
@@ -10,6 +10,7 @@ export class DomainFactory {
generated: string[] = []; generated: string[] = [];
history: Domain[] = []; history: Domain[] = [];
tldList: string[] = []; tldList: string[] = [];
ignoredTldList: string[] = [];
async init(lang: string | null = null) { async init(lang: string | null = null) {
if (lang && !this.words[lang]) { if (lang && !this.words[lang]) {
@@ -58,6 +59,9 @@ export class DomainFactory {
randomDomain(word: string): string | null { randomDomain(word: string): string | null {
for (const tld of shuffled(this.tldList.slice())) { for (const tld of shuffled(this.tldList.slice())) {
if (this.ignoredTld(tld)) {
continue;
}
const tldEscaped: string = tld.replace(".", ""); const tldEscaped: string = tld.replace(".", "");
if (word.endsWith(tldEscaped) && word.length > tldEscaped.length + 2) { if (word.endsWith(tldEscaped) && word.length > tldEscaped.length + 2) {
const domain = `${word.substring(0, word.length - tldEscaped.length)}.${tld}`; const domain = `${word.substring(0, word.length - tldEscaped.length)}.${tld}`;
@@ -93,8 +97,8 @@ export class DomainFactory {
}); });
} }
removeExt(ext: string): void { removeExtensions(...extensions: string[]): void {
this.tldList = this.tldList.filter((tld: string) => tld !== ext && !tld.endsWith(ext)); this.ignoredTldList.push(...extensions);
} }
newDomain(domain: string): Domain { newDomain(domain: string): Domain {
@@ -106,6 +110,10 @@ export class DomainFactory {
}; };
} }
ignoredTld(tld: string): boolean {
return this.ignoredTldList.some((ignoredTld: string) => tld.endsWith(ignoredTld));
}
allFromWord(word: string): Promise<Domain[]> { allFromWord(word: string): Promise<Domain[]> {
const escapedWord = this.escapeWord(word.replace(/ /gm, "-")); const escapedWord = this.escapeWord(word.replace(/ /gm, "-"));
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -113,6 +121,9 @@ export class DomainFactory {
.then(() => { .then(() => {
const domains = []; const domains = [];
for (const tld of shuffled(this.tldList.slice())) { for (const tld of shuffled(this.tldList.slice())) {
if (this.ignoredTld(tld)) {
continue;
}
const tldEscaped: string = tld.replace(".", ""); const tldEscaped: string = tld.replace(".", "");
if (escapedWord.endsWith(tldEscaped) && escapedWord.length >= tldEscaped.length + 2) { if (escapedWord.endsWith(tldEscaped) && escapedWord.length >= tldEscaped.length + 2) {
const domain = `${escapedWord.substring(0, escapedWord.length - tldEscaped.length)}.${tld}`; const domain = `${escapedWord.substring(0, escapedWord.length - tldEscaped.length)}.${tld}`;