From 5f465dbc4a006be6c8d62d5130eb4044065aca97 Mon Sep 17 00:00:00 2001 From: Julian Rabe Date: Fri, 4 Nov 2022 16:46:14 +0100 Subject: [PATCH 1/4] fix: remove non-ASCII characters from domain words --- src/locales/en/word/noun.ts | 1 - src/modules/internet/index.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/locales/en/word/noun.ts b/src/locales/en/word/noun.ts index da46f56e9c4..65a55b92ec0 100644 --- a/src/locales/en/word/noun.ts +++ b/src/locales/en/word/noun.ts @@ -3244,7 +3244,6 @@ export default [ 'jaguar', 'jail', 'jailhouse', - 'jalapeño', 'jam', 'jar', 'jasmine', diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 60e3ac55a46..5120aeb162e 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -290,7 +290,7 @@ export class InternetModule { */ domainWord(): string { return `${this.faker.word.adjective()}-${this.faker.word.noun()}` - .replace(/([\\~#&*{}/:<>?|\"'])/gi, '') + .replace(/([^a-z0-9-])/gi, '') .replace(/\s/g, '-') .replace(/-{2,}/g, '-') .toLowerCase(); From 1edd655cebf73e1e7e9096cc4aea08aaa40f5e72 Mon Sep 17 00:00:00 2001 From: Julian Rabe Date: Mon, 12 Dec 2022 15:26:21 +0100 Subject: [PATCH 2/4] Revert "fix: remove non-ASCII characters from domain words" This reverts commit 5f465dbc4a006be6c8d62d5130eb4044065aca97. --- src/locales/en/word/noun.ts | 1 + src/modules/internet/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/locales/en/word/noun.ts b/src/locales/en/word/noun.ts index 65a55b92ec0..da46f56e9c4 100644 --- a/src/locales/en/word/noun.ts +++ b/src/locales/en/word/noun.ts @@ -3244,6 +3244,7 @@ export default [ 'jaguar', 'jail', 'jailhouse', + 'jalapeño', 'jam', 'jar', 'jasmine', diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 50419b7cd84..4f3132752be 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -359,7 +359,7 @@ export class InternetModule { */ domainWord(): string { return `${this.faker.word.adjective()}-${this.faker.word.noun()}` - .replace(/([^a-z0-9-])/gi, '') + .replace(/([\\~#&*{}/:<>?|\"'])/gi, '') .replace(/\s/g, '-') .replace(/-{2,}/g, '-') .toLowerCase(); From 6813cde09ebc3dfdee01df72e511131e3d40d948 Mon Sep 17 00:00:00 2001 From: Julian Rabe Date: Mon, 12 Dec 2022 15:35:45 +0100 Subject: [PATCH 3/4] fix: ASCII-fy `domainWord()` --- src/modules/internet/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 4f3132752be..3eaf89e3f5c 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -358,8 +358,8 @@ export class InternetModule { * @since 2.0.1 */ domainWord(): string { - return `${this.faker.word.adjective()}-${this.faker.word.noun()}` - .replace(/([\\~#&*{}/:<>?|\"'])/gi, '') + return this.faker.helpers + .slugify(`${this.faker.word.adjective()}-${this.faker.word.noun()}`) .replace(/\s/g, '-') .replace(/-{2,}/g, '-') .toLowerCase(); From c7202914baebedf29ef9fec6fbe7bd3af1e48bbf Mon Sep 17 00:00:00 2001 From: Julian Rabe Date: Mon, 12 Dec 2022 16:32:38 +0100 Subject: [PATCH 4/4] fix: let `domainWord()` depend on `slugify()` to convert spaces --- src/modules/internet/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 3eaf89e3f5c..2bac0668928 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -360,8 +360,6 @@ export class InternetModule { domainWord(): string { return this.faker.helpers .slugify(`${this.faker.word.adjective()}-${this.faker.word.noun()}`) - .replace(/\s/g, '-') - .replace(/-{2,}/g, '-') .toLowerCase(); }