From d9f74b29157ab85fbf2a55a5b7861cc04ae184d0 Mon Sep 17 00:00:00 2001 From: Paolo del Mundo Date: Tue, 6 Sep 2016 11:36:49 -0400 Subject: Add separator --- lib/internet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/internet.js b/lib/internet.js index 2d7ff530..92a1bd24 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -281,12 +281,12 @@ var Internet = function (faker) { * * @method faker.internet.mac */ - self.mac = function(){ + self.mac = function(sep){ var i, mac = ""; for (i=0; i < 12; i++) { mac+= faker.random.number(15).toString(16); if (i%2==1 && i != 11) { - mac+=":"; + mac+=sep || ":"; } } return mac; -- cgit v1.2.3 From f52951ae1b87b244056a111bb6d59b6c287cc4cb Mon Sep 17 00:00:00 2001 From: Paolo del Mundo Date: Sun, 25 Sep 2016 23:50:19 -0400 Subject: separator enhancements and unit tests --- lib/internet.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/internet.js b/lib/internet.js index 92a1bd24..7586335d 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -282,11 +282,20 @@ var Internet = function (faker) { * @method faker.internet.mac */ self.mac = function(sep){ - var i, mac = ""; + var i, + mac = "", + validSep = ':'; + + // if the client passed in a different separator than `:`, + // we will use it if it is in the list of acceptable separators (dash or no separator) + if (['-', ''].indexOf(sep) !== -1) { + validSep = sep; + } + for (i=0; i < 12; i++) { mac+= faker.random.number(15).toString(16); if (i%2==1 && i != 11) { - mac+=sep || ":"; + mac+=validSep; } } return mac; -- cgit v1.2.3 From 5cf0d78de1c28a9a5cd0217696ca297ff1e126df Mon Sep 17 00:00:00 2001 From: Paolo del Mundo Date: Mon, 26 Sep 2016 00:03:42 -0400 Subject: Comments --- lib/internet.js | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/internet.js b/lib/internet.js index 7586335d..58303d23 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -280,6 +280,7 @@ var Internet = function (faker) { * mac * * @method faker.internet.mac + * @param {string} sep */ self.mac = function(sep){ var i, -- cgit v1.2.3