aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2017-03-02 15:19:16 -0500
committerGitHub <[email protected]>2017-03-02 15:19:16 -0500
commit6cdb93efcbcaf222ac061cee5532374f72ea073e (patch)
treea4f23c1114abc37c406ea3203a2e28bfc9e050e2 /lib
parent8c43fe8f7cf81b60fc77be5510228ec8bd38f9d3 (diff)
parent5cf0d78de1c28a9a5cd0217696ca297ff1e126df (diff)
downloadfaker-6cdb93efcbcaf222ac061cee5532374f72ea073e.tar.xz
faker-6cdb93efcbcaf222ac061cee5532374f72ea073e.zip
Merge pull request #408 from paolo-tanium/allow-mac-to-specify-separator
[api] Allow user to specify separator to be used in mac address
Diffstat (limited to 'lib')
-rw-r--r--lib/internet.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/internet.js b/lib/internet.js
index 0de5ef65..ca33672d 100644
--- a/lib/internet.js
+++ b/lib/internet.js
@@ -305,13 +305,23 @@ var Internet = function (faker) {
* mac
*
* @method faker.internet.mac
+ * @param {string} sep
*/
- self.mac = function(){
- var i, mac = "";
+ self.mac = function(sep){
+ 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+=":";
+ mac+=validSep;
}
}
return mac;