<commit_before>var program = require('commander')
	, pkg = require('./package.json')
	, url = require('url')

var urlFixer = function (theUrl) {
	var urlObj = url.parse(theUrl)
		, obj = {}
		, keys = ['protocol', 'slashes', 'auth', 'hostname']
		, str

	keys.forEach(function (key) {
		obj[key] = urlObj[key]
	})

	if (obj.protocol === undefined || obj.hostname === undefined) {
		return false
	}

	obj.port = urlObj.port? urlObj.port: 8080
	str = url.format(obj)
	if (str === '') {
		return false
	}

	// TODO: validate str as a url
	return str
}

program
  .version(pkg.version)
  .description(pkg.description)

program
	.command('setup')
	.description('setup configuration for developing behind the proxy')
  .option('--http <url>', 'set url for http proxy (e.g. http://myproxy.com:8080)', urlFixer)
  .option('--https <url>', 'set url for https proxy (e.g. https://me:mypass@myproxy.com:443', urlFixer)
  .option('--same', 'use the same http proxy for https')
  .option('--save', 'save settings')
	.action(function (options) {
		console.log('http=', options.http)
		console.log('https=', options.https)<commit_msg>Change urlFixer to urlValidator<commit_after>var program = require('commander')
	, pkg = require('./package.json')
	, url = require('url')

var urlValidator = function (theUrl) {
	var reUrl = /^https?:\/\/(?:(\w+)(?:[:](\w+))?[@])?([A-Za-z0-9-]+(?:[.][A-Za-z0-9-]+)*|(\d{1,3}(?:[.]\d{1,3}){3}))[:](\d+)$/
	return reUrl.exec(theUrl) === null? false: theUrl
}

program
  .version(pkg.version)
  .description(pkg.description)

program
	.command('setup')
	.description('setup configuration for developing behind the proxy')
  .option('--http <url>', 'set url for http proxy (e.g. http://myproxy.com:8080)', urlValidator)
  .option('--https <url>', 'set url for https proxy (e.g. https://me:mypass@myproxy.com:443', urlValidator)
  .option('--same', 'use the same http proxy for https')
  .option('--save', 'save settings')
	.action(function (options) {
		console.log('http=', options.http)
		console.log('https=', options.https)
{'fraction_non_alphanumeric': 0.21047479197258934, 'fraction_numerical': 0.013215859030837005, 'mean_word_length': 4.214285714285714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '429243', 'n_tokens_mistral': 752, 'n_tokens_neox': 721, 'n_words': 169}