From 46516d5fbb2562f3276416930ef28e6b8c52a92a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 19 Dec 2015 02:18:32 -0800 Subject: [PATCH] merge utils,common -> common --- index.js | 2 +- lib/common.js | 17 +++++++++++++++++ lib/utils.js | 20 -------------------- 3 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 lib/utils.js diff --git a/index.js b/index.js index a6af16e..3f2af93 100644 --- a/index.js +++ b/index.js @@ -107,7 +107,7 @@ LE.create = function (defaults, handlers, backend) { backend = PromiseA.promisifyAll(backend); - var utils = require('./lib/utils'); + var utils = require('./lib/common'); //var attempts = {}; // should exist in master process only var le; diff --git a/lib/common.js b/lib/common.js index 0c7a667..36cf6f8 100644 --- a/lib/common.js +++ b/lib/common.js @@ -3,6 +3,23 @@ var fs = require('fs'); var PromiseA = require('bluebird'); +var re = /^[a-zA-Z0-9\.\-]+$/; +var punycode = require('punycode'); + +mudole.exports.isValidDomain = function (domain) { + if (re.test(domain)) { + return domain; + } + + domain = punycode.toASCII(domain); + + if (re.test(domain)) { + return domain; + } + + return ''; +}; + module.exports.tplConfigDir = function merge(configDir, defaults) { Object.keys(defaults).forEach(function (key) { if ('string' === typeof defaults[key]) { diff --git a/lib/utils.js b/lib/utils.js deleted file mode 100644 index 545a65c..0000000 --- a/lib/utils.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var re = /^[a-zA-Z0-9\.\-]+$/; -var punycode = require('punycode'); - -var utils = module.exports; - -utils.isValidDomain = function (domain) { - if (re.test(domain)) { - return domain; - } - - domain = punycode.toASCII(domain); - - if (re.test(domain)) { - return domain; - } - - return ''; -};