aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarak <[email protected]>2016-02-08 03:30:34 +0530
committerMarak <[email protected]>2016-02-08 03:30:34 +0530
commitd50103dca36292c07a88a09a3f1b0bf704e978b0 (patch)
treead0571db48526cb4da4c935dacb5a37b66c1a8d3
parent03950629e23566a0e74a43bab4a01cf7d21e7852 (diff)
parentf74bafc07d2713151446e917b254a25a1660a45e (diff)
downloadfaker-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.js4
-rw-r--r--test/internet.unit.js10
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 () {