Browse Source

up proxy works perfectly!

pull/1/head
Muthu Kumar 7 years ago
parent
commit
089997d122
  1. 2
      index.js
  2. 6
      util/validate.js

2
index.js

@ -40,7 +40,7 @@ program
.command('static <domain> [outPort]') .command('static <domain> [outPort]')
.description('Create a static server at this folder.') .description('Create a static server at this folder.')
.action(function(domain, outPort="80") { .action(function(domain, outPort="80") {
// stuff happens if(!validate(domain, outPort))
createStaticServer(domain, outPort) createStaticServer(domain, outPort)
}) })

6
util/validate.js

@ -2,7 +2,7 @@ var validator = require('validator')
// Using Validator // Using Validator
var isDomain = validator.isFQDN var isDomain = validator.isFQDN
function validate(domain, inPort, outPort = undefined) { function validate(domain, inPort = undefined, outPort) {
var domainInvalidMsg = "\nDomain is not valid. Please use a valid domain name." var domainInvalidMsg = "\nDomain is not valid. Please use a valid domain name."
var portInvalidMsg = ["\nPort should be a number.", "\nPort should be a number from 1 and 65535."] var portInvalidMsg = ["\nPort should be a number.", "\nPort should be a number from 1 and 65535."]
var validInPort = /^\d+$/.exec(inPort) var validInPort = /^\d+$/.exec(inPort)
@ -21,13 +21,12 @@ function validate(domain, inPort, outPort = undefined) {
console.log(portInvalidMsg[1]) console.log(portInvalidMsg[1])
return isTrue = false return isTrue = false
} }
} /* }
if (typeof outPort !== undefined) { if (typeof outPort !== undefined) {
if (!validInPort || !validOutPort) { if (!validInPort || !validOutPort) {
console.log(portInvalidMsg[0]) console.log(portInvalidMsg[0])
return isTrue = false return isTrue = false
} }
} */
if (typeof outPort !== undefined) { if (typeof outPort !== undefined) {
if (!((validInPort > 0 && validInPort <= 65535) && (validOutPort > 0 && validOutPort <= 65535))) { if (!((validInPort > 0 && validInPort <= 65535) && (validOutPort > 0 && validOutPort <= 65535))) {
console.log(portInvalidMsg[1]) console.log(portInvalidMsg[1])
@ -36,5 +35,6 @@ function validate(domain, inPort, outPort = undefined) {
} }
return isTrue return isTrue
} }
}
module.exports = validate module.exports = validate
Loading…
Cancel
Save