feat: dont generate xxx domains
This commit is contained in:
@@ -60,6 +60,13 @@ function checkAvailability() {
|
||||
}
|
||||
}
|
||||
|
||||
function removeExt() {
|
||||
if (domain.value) {
|
||||
props.factory.removeExt(domain.value.extension);
|
||||
newDomain();
|
||||
}
|
||||
}
|
||||
|
||||
function getTextClass() {
|
||||
if (!domain.value || domain.value.name.length < 15) {
|
||||
return "text-5xl";
|
||||
@@ -121,5 +128,14 @@ watch(i18n.locale, newDomain);
|
||||
>
|
||||
{{ $t("button.new_domain") }}
|
||||
</button>
|
||||
<br />
|
||||
<p v-if="domain && state === State.Ready">
|
||||
<small
|
||||
><a class="underline" href="#" @click.prevent="removeExt">{{
|
||||
$t("page_random.dont_suggest", { ext: `.${domain.extension}` })
|
||||
}}</a></small
|
||||
>
|
||||
</p>
|
||||
<p v-else> </p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+25
-24
@@ -1,27 +1,28 @@
|
||||
{
|
||||
"tab": {
|
||||
"random": "Random",
|
||||
"input": "Input",
|
||||
"history": "History"
|
||||
},
|
||||
"this_domain": "This domain",
|
||||
"is_unavailable": "is not available",
|
||||
"seems": "seems",
|
||||
"available": "available",
|
||||
"error": "An error has occured, please reload the page.",
|
||||
"page_random": {
|
||||
"state": {
|
||||
"loading": "Loading the Cool Domain Factory™",
|
||||
"generating": "Generating a new cool domain",
|
||||
"fetching": "Checking domain availability"
|
||||
"tab": {
|
||||
"random": "Random",
|
||||
"input": "Input",
|
||||
"history": "History"
|
||||
},
|
||||
"this_domain": "This domain",
|
||||
"is_unavailable": "is not available",
|
||||
"seems": "seems",
|
||||
"available": "available",
|
||||
"error": "An error has occured, please reload the page.",
|
||||
"page_random": {
|
||||
"state": {
|
||||
"loading": "Loading the Cool Domain Factory™",
|
||||
"generating": "Generating a new cool domain",
|
||||
"fetching": "Checking domain availability"
|
||||
},
|
||||
"dont_suggest": "Don't generate {ext} domains"
|
||||
},
|
||||
"page_input": {
|
||||
"not_found": "No matching domain found.",
|
||||
"placeholder": "Type a word or a phrase"
|
||||
},
|
||||
"button": {
|
||||
"new_domain": "New domain",
|
||||
"generate": "Generate"
|
||||
}
|
||||
},
|
||||
"page_input": {
|
||||
"not_found": "No matching domain found.",
|
||||
"placeholder": "Type a word or a phrase"
|
||||
},
|
||||
"button": {
|
||||
"new_domain": "New domain",
|
||||
"generate": "Generate"
|
||||
}
|
||||
}
|
||||
|
||||
+25
-24
@@ -1,27 +1,28 @@
|
||||
{
|
||||
"tab": {
|
||||
"random": "Aléatoire",
|
||||
"input": "Saisie",
|
||||
"history": "Historique"
|
||||
},
|
||||
"this_domain": "Ce domaine",
|
||||
"is_unavailable": "n'est pas disponible",
|
||||
"seems": "semble être",
|
||||
"available": "disponible",
|
||||
"error": "Une erreur est survenue, merci de recharger la page.",
|
||||
"page_random": {
|
||||
"state": {
|
||||
"loading": "Chargement de la Cool Domain Factory™",
|
||||
"generating": "Création d'un domaine cool",
|
||||
"fetching": "Vérification de la disponibilité"
|
||||
"tab": {
|
||||
"random": "Aléatoire",
|
||||
"input": "Saisie",
|
||||
"history": "Historique"
|
||||
},
|
||||
"this_domain": "Ce domaine",
|
||||
"is_unavailable": "n'est pas disponible",
|
||||
"seems": "semble être",
|
||||
"available": "disponible",
|
||||
"error": "Une erreur est survenue, merci de recharger la page.",
|
||||
"page_random": {
|
||||
"state": {
|
||||
"loading": "Chargement de la Cool Domain Factory™",
|
||||
"generating": "Création d'un domaine cool",
|
||||
"fetching": "Vérification de la disponibilité"
|
||||
},
|
||||
"dont_suggest": "Ne pas génerer des domaines en {ext}"
|
||||
},
|
||||
"page_input": {
|
||||
"not_found": "Aucun domaine correspondant.",
|
||||
"placeholder": "Écrit un mot ou une phrase."
|
||||
},
|
||||
"button": {
|
||||
"new_domain": "Nouveau domaine",
|
||||
"generate": "Génerer"
|
||||
}
|
||||
},
|
||||
"page_input": {
|
||||
"not_found": "Aucun domaine correspondant.",
|
||||
"placeholder": "Écrit un mot ou une phrase."
|
||||
},
|
||||
"button": {
|
||||
"new_domain": "Nouveau domaine",
|
||||
"generate": "Génerer"
|
||||
}
|
||||
}
|
||||
|
||||
+20
-8
@@ -11,10 +11,12 @@ export class DomainFactory {
|
||||
words: Record<string, string[]> = {};
|
||||
generated: string[] = [];
|
||||
history: Domain[] = [];
|
||||
tldList: string[] = [];
|
||||
|
||||
init() {
|
||||
this.words.fr = this.initWords(frenchWords);
|
||||
this.words.en = this.initWords(englishWords);
|
||||
this.tldList = TLD_LIST;
|
||||
}
|
||||
|
||||
escapeWord(word: string): string {
|
||||
@@ -47,7 +49,7 @@ export class DomainFactory {
|
||||
}
|
||||
|
||||
randomDomain(word: string): string | null {
|
||||
for (const tld of shuffled(TLD_LIST.slice())) {
|
||||
for (const tld of shuffled(this.tldList.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}`;
|
||||
@@ -68,7 +70,7 @@ export class DomainFactory {
|
||||
const word = this.randomWord(lang);
|
||||
const domain = this.randomDomain(word);
|
||||
if (domain) {
|
||||
const output = { name: domain, searching: false, available: true };
|
||||
const output = this.newDomain(domain);
|
||||
this.history.push(output);
|
||||
resolve(output);
|
||||
return;
|
||||
@@ -79,19 +81,29 @@ export class DomainFactory {
|
||||
});
|
||||
}
|
||||
|
||||
removeExt(ext: string): void {
|
||||
this.tldList = this.tldList.filter((tld: string) => tld !== ext && !tld.endsWith(ext));
|
||||
}
|
||||
|
||||
newDomain(domain: string): Domain {
|
||||
return {
|
||||
name: domain,
|
||||
extension: domain.split(".", 1)[1] ?? "",
|
||||
searching: false,
|
||||
available: true,
|
||||
};
|
||||
}
|
||||
|
||||
allFromWord(word: string): Promise<Domain[]> {
|
||||
const escapedWord = this.escapeWord(word.replace(/ /gm, "-"));
|
||||
return new Promise((resolve, reject) => {
|
||||
const domains = [];
|
||||
for (const tld of shuffled(TLD_LIST.slice())) {
|
||||
for (const tld of shuffled(this.tldList.slice())) {
|
||||
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}`;
|
||||
if (!domain.includes("-.")) {
|
||||
const output = { name: domain, searching: false, available: true };
|
||||
const output = this.newDomain(domain);
|
||||
this.history.push(output);
|
||||
domains.push(output);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface WhoIsEntity {
|
||||
|
||||
export interface Domain {
|
||||
name: string;
|
||||
extension: string;
|
||||
available: boolean;
|
||||
searching: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user