Skip to content

Commit 27216e1

Browse files
authored
Merge branch 'next' into refactor/changelog-include-locale-changes
2 parents a67a404 + 2e6b136 commit 27216e1

File tree

8 files changed

+52
-3
lines changed

8 files changed

+52
-3
lines changed

src/locales/el/person/last_name.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default [
3232
'Αρβανίτης',
3333
'Αργυριάδης',
3434
'Ασπάσιος',
35-
'Αυγερινός (επώνυμο)',
35+
'Αυγερινός',
3636
'Βάμβας',
3737
'Βαμβακάς',
3838
'Βαρνακιώτης',
@@ -147,7 +147,7 @@ export default [
147147
'Λόντος',
148148
'Λύτρας',
149149
'Λαγός',
150-
'Λαιμός (επώνυμο)',
150+
'Λαιμός',
151151
'Λαμέρας',
152152
'Λαμπρόπουλος',
153153
'Λειβαδάς',

src/locales/fa/person/last_name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default [
5757
'کوشکی',
5858
'کهنمویی',
5959
'کیان',
60-
'کیانی (نام خانوادگی)',
60+
'کیانی',
6161
'کیمیایی',
6262
'گل محمدی',
6363
'گلپایگانی',

src/locales/hu/company/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
import type { CompanyDefinitions } from '../../..';
6+
import name_patterns from './name_patterns';
7+
import suffix from './suffix';
8+
9+
const company: CompanyDefinitions = {
10+
name_patterns,
11+
suffix,
12+
};
13+
14+
export default company;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default [
2+
'{{person.last_name}} {{company.suffix}}',
3+
'{{person.last_name}} és {{person.last_name}} {{company.suffix}}',
4+
'{{person.last_name}} és Tsa. {{company.suffix}}',
5+
'{{person.last_name}} 2000 {{company.suffix}}',
6+
];

src/locales/hu/company/suffix.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default ['Kft.', 'Bt.', 'Zrt.', 'Nyrt.', 'Kv.', 'Kkt.'];

src/locales/hu/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type { LocaleDefinition } from '../..';
66
import animal from './animal';
77
import commerce from './commerce';
8+
import company from './company';
89
import date from './date';
910
import finance from './finance';
1011
import internet from './internet';
@@ -16,6 +17,7 @@ const hu: LocaleDefinition = {
1617
title: 'Hungarian',
1718
animal,
1819
commerce,
20+
company,
1921
date,
2022
finance,
2123
internet,

src/modules/internet/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ export class InternetModule {
9191
);
9292

9393
let localPart: string = this.userName(firstName, lastName);
94+
// Strip any special characters from the local part of the email address
95+
// This could happen if invalid chars are passed in manually in the firstName/lastName
96+
localPart = localPart.replace(/[^A-Za-z0-9._+\-]+/g, '');
97+
98+
// The local part of an email address is limited to 64 chars per RFC 3696
99+
// We limit to 50 chars to be more realistic
100+
localPart = localPart.substring(0, 50);
94101
if (options?.allowSpecialCharacters) {
95102
const usernameChars: string[] = '._-'.split('');
96103
const specialChars: string[] = ".!#$%&'*+-/=?^_`{|}~".split('');

test/internet.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ describe('internet', () => {
156156
expect(faker.definitions.internet.free_email).toContain(suffix);
157157
});
158158

159+
it('should return a valid email for very long names', () => {
160+
const longFirstName =
161+
'Elizabeth Alexandra Mary Jane Annabel Victoria';
162+
const longSurname = 'Smith Jones Davidson Brown White Greene Black';
163+
const email = faker.internet.email(longFirstName, longSurname);
164+
// should truncate to 50 chars
165+
// e.g. ElizabethAlexandraMaryJaneAnnabelVictoria.SmithJon@yahoo.com
166+
expect(email).toSatisfy(validator.isEmail);
167+
const localPart = email.split('@')[0];
168+
expect(localPart.length).toBeLessThanOrEqual(50);
169+
});
170+
171+
it('should return a valid email for names with invalid chars', () => {
172+
const email = faker.internet.email('Matthew (Matt)', 'Smith');
173+
// should strip invalid chars
174+
// e.g. MatthewMatt_Smith@yahoo.com
175+
expect(email).toSatisfy(validator.isEmail);
176+
});
177+
159178
it('should return an email with special characters', () => {
160179
const email = faker.internet.email('Mike', 'Smith', null, {
161180
allowSpecialCharacters: true,

0 commit comments

Comments
 (0)