From a8dc7e07f6d5ee2ae38724ba5d503d7b88bd7147 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Mon, 1 May 2023 16:03:00 +0700 Subject: fix(location): no leading zero on building number or secondary address (#2032) --- src/modules/location/index.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/modules') diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index e924bd7e..5b5d37a1 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -188,11 +188,14 @@ export class LocationModule { * @since 8.0.0 */ buildingNumber(): string { - const format = this.faker.helpers.arrayElement( - this.faker.definitions.location.building_number - ); - - return this.faker.helpers.replaceSymbolWithNumber(format); + return this.faker.helpers + .arrayElement(this.faker.definitions.location.building_number) + .replace(/#+/g, (m) => + this.faker.string.numeric({ + length: m.length, + allowLeadingZeros: false, + }) + ); } /** @@ -281,11 +284,14 @@ export class LocationModule { * @since 8.0.0 */ secondaryAddress(): string { - return this.faker.helpers.replaceSymbolWithNumber( - this.faker.helpers.arrayElement( - this.faker.definitions.location.secondary_address - ) - ); + return this.faker.helpers + .arrayElement(this.faker.definitions.location.secondary_address) + .replace(/#+/g, (m) => + this.faker.string.numeric({ + length: m.length, + allowLeadingZeros: false, + }) + ); } /** -- cgit v1.2.3