diff options
| author | Marak <[email protected]> | 2016-02-08 03:30:34 +0530 |
|---|---|---|
| committer | Marak <[email protected]> | 2016-02-08 03:30:34 +0530 |
| commit | d50103dca36292c07a88a09a3f1b0bf704e978b0 (patch) | |
| tree | ad0571db48526cb4da4c935dacb5a37b66c1a8d3 | |
| parent | 03950629e23566a0e74a43bab4a01cf7d21e7852 (diff) | |
| parent | f74bafc07d2713151446e917b254a25a1660a45e (diff) | |
| download | faker-d50103dca36292c07a88a09a3f1b0bf704e978b0.tar.xz faker-d50103dca36292c07a88a09a3f1b0bf704e978b0.zip | |
Merge pull request #326 from puhastudio/internet-domainwords
[fix] Prevent apostrophes in return value of internet#domainWords
| -rw-r--r-- | lib/internet.js | 4 | ||||
| -rw-r--r-- | test/internet.unit.js | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/internet.js b/lib/internet.js index 2663ce5c..c9626a17 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -50,7 +50,7 @@ var Internet = function (faker) { }; self.domainWord = function () { - return faker.name.firstName().replace(/([\\~#&*{}/:<>?|\"])/ig, '').toLowerCase(); + return faker.name.firstName().replace(/([\\~#&*{}/:<>?|\"'])/ig, '').toLowerCase(); }; self.ip = function () { @@ -106,7 +106,7 @@ var Internet = function (faker) { } return password_generator(len, memorable, pattern, prefix); } - + }; diff --git a/test/internet.unit.js b/test/internet.unit.js index 9218a56e..5ed0b664 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -72,6 +72,16 @@ describe("internet.js", function () { faker.name.firstName.restore(); }); + describe("when the firstName used contains a apostrophe", function () { + sinon.stub(faker.name, 'firstName').returns('d\'angelo'); + var domain_word = faker.internet.domainWord(); + + it("should remove the apostrophe", function () { + assert.strictEqual(domain_word, 'dangelo'); + }); + + faker.name.firstName.restore(); + }); }); describe('protocol()', function () { |
