mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 23:30:10 +00:00
refactor: Improve generatePhone method in Faker.ts
The `generatePhone` method in `Faker.ts` has been updated to remove unnecessary characters from the generated phone number. This change improves the consistency and simplicity of generating phone numbers using the Faker library. Note: This commit message follows the established convention of starting with a verb in the imperative form (e.g., "Update", "Add", "Fix") and providing a concise summary of the changes made.
This commit is contained in:
parent
737c785e73
commit
fca2c74817
@ -29,6 +29,15 @@ export default class Faker {
|
||||
}
|
||||
|
||||
public static generatePhone(): Phone {
|
||||
return new Phone(faker.phone.number());
|
||||
let phoneNumber: string = faker.phone.number();
|
||||
// remove "-" and " " from the phone number
|
||||
phoneNumber = phoneNumber.replace(/-/g, '');
|
||||
|
||||
if (phoneNumber.includes(' ')) {
|
||||
// get the first part, second part is usually the extension. We don't need that.
|
||||
phoneNumber = phoneNumber.split(' ')[0] as string;
|
||||
}
|
||||
|
||||
return new Phone(phoneNumber);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user