fix: tld-list link with correct extension
Deploy / Deploy to Stapler (push) Has been cancelled
Deploy / Build (push) Has been cancelled
Lint / ESLint (push) Has been cancelled
Lint / Oxlint (push) Has been cancelled
Lint / TypeScript (push) Has been cancelled

This commit is contained in:
2026-06-26 14:26:31 +02:00
parent e5ab509c29
commit b8e08cb208
4 changed files with 19 additions and 6 deletions
+3 -1
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, defineAsyncComponent } from "vue"; import { ref, onMounted, defineAsyncComponent, onBeforeMount } from "vue";
const PageRandom = defineAsyncComponent(() => import("@/components/PageRandom.vue")); const PageRandom = defineAsyncComponent(() => import("@/components/PageRandom.vue"));
const PageInput = defineAsyncComponent(() => import("@/components/PageInput.vue")); const PageInput = defineAsyncComponent(() => import("@/components/PageInput.vue"));
const PageHistory = defineAsyncComponent(() => import("./components/PageHistory.vue")); const PageHistory = defineAsyncComponent(() => import("./components/PageHistory.vue"));
@@ -8,6 +8,8 @@ import { DomainFactory } from "@/lib/factory";
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
const factory = ref<DomainFactory>(new DomainFactory()); const factory = ref<DomainFactory>(new DomainFactory());
onBeforeMount(() => {});
onMounted(() => { onMounted(() => {
setTimeout(() => { setTimeout(() => {
visible.value = true; visible.value = true;
+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}`;