From cab6575c7378cc8f1e6426acc47fac09b415e21b Mon Sep 17 00:00:00 2001 From: Tom Collier Date: Thu, 30 Jul 2015 09:42:27 -0700 Subject: Only append suffix to streetName if suffix is present When streetSuffix returns an empty string, do not append a space to the end of the name part of streetName. With the prior behavior, occasionally, this streetName would return something like "Ashley " (notice the trailing space), which is undesirable in many circumstances. --- lib/address.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/address.js b/lib/address.js index c0a64f69..35031a63 100644 --- a/lib/address.js +++ b/lib/address.js @@ -41,12 +41,17 @@ function Address (faker) { this.streetName = function () { var result; + var suffix = faker.address.streetSuffix(); + if (suffix !== "") { + suffix = " " + suffix + } + switch (faker.random.number(1)) { case 0: - result = faker.name.lastName() + " " + faker.address.streetSuffix(); + result = faker.name.lastName() + suffix; break; case 1: - result = faker.name.firstName() + " " + faker.address.streetSuffix(); + result = faker.name.firstName() + suffix; break; } return result; -- cgit v1.2.3