fix: tld-list link with correct extension
This commit is contained in:
@@ -62,7 +62,7 @@ function newDomain() {
|
|||||||
<span v-else-if="domain.available"
|
<span v-else-if="domain.available"
|
||||||
> {{ $t("seems") }}
|
> {{ $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
|
||||||
|
|||||||
@@ -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
@@ -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}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user