aboutsummaryrefslogtreecommitdiff
path: root/src/modules/helpers
diff options
context:
space:
mode:
authorMatt Mayer <[email protected]>2022-12-04 03:15:36 +0700
committerGitHub <[email protected]>2022-12-03 21:15:36 +0100
commit4ed45fa33f80c59625a285d06abe31ce2f524357 (patch)
treea01624a3f23004160fcbe63533358ae8819d67ca /src/modules/helpers
parent5e51335e19426820874c75678ee5a7ebd332a911 (diff)
downloadfaker-4ed45fa33f80c59625a285d06abe31ce2f524357.tar.xz
faker-4ed45fa33f80c59625a285d06abe31ce2f524357.zip
fix(internet): userName, email and slugify return only ascii (#1554)
Diffstat (limited to 'src/modules/helpers')
-rw-r--r--src/modules/helpers/index.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index 6caa8eff..7f2c5898 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -33,8 +33,10 @@ export class HelpersModule {
*/
slugify(string: string = ''): string {
return string
- .replace(/ /g, '-')
- .replace(/[^\一-龠\ぁ-ゔ\ァ-ヴー\w\.\-]+/g, '');
+ .normalize('NFKD') //for example è decomposes to as e + ̀
+ .replace(/[\u0300-\u036f]/g, '') // removes combining marks
+ .replace(/ /g, '-') // replaces spaces with hyphens
+ .replace(/[^\w\.\-]+/g, ''); // removes all non-word characters except for dots and hyphens
}
/**