Comparing version 0.3.6 to 0.3.7
@@ -7,2 +7,3 @@ | ||
var http = require('http'), | ||
https = require('https'), | ||
cheerio = require('cheerio'), | ||
@@ -92,5 +93,11 @@ uglify = require('uglify-js'), | ||
num_inline=0, | ||
src; | ||
src, | ||
request = http; | ||
http.get(website, function (res) { | ||
if (helper.isHttps(website)) { | ||
request = https; | ||
} | ||
request.get(website, function (res) { | ||
var body = ''; | ||
@@ -117,6 +124,5 @@ | ||
var inline = $(this).text(); | ||
inline = inline.replace(/<!--[\s\S]*?-->/g, ""); | ||
scripts.push({type: 'inline', data: inline}); | ||
num_inline++; | ||
@@ -143,3 +149,3 @@ self.echoMsg('found inline script(' + num_inline + ')', 'info'); | ||
var self = this, parsedUrl; | ||
var self = this, parsedUrl, request = http; | ||
@@ -149,4 +155,9 @@ parsedUrl = helper.resolveUrl(urlStr, website, flag); | ||
self.echoMsg('downloading ' + chalk.yellow(parsedUrl), 'info'); | ||
http.get(parsedUrl, function (res) { | ||
if (helper.isHttps(parsedUrl)) { | ||
request = https; | ||
} | ||
request.get(parsedUrl, function (res) { | ||
var script = ''; | ||
@@ -240,2 +251,4 @@ | ||
Performs maximun compression | ||
@param: code (String) | ||
*/ | ||
@@ -246,9 +259,7 @@ maxCompression: function (code) { | ||
var ast = uglify.parse(code), compressor; | ||
// compressor - reduces the code size by applying various optimizations | ||
ast.figure_out_scope(); | ||
compressor = uglify.Compressor(); | ||
ast = ast.transform(compressor); | ||
// Name Mangler - reduces names of local variables and functions | ||
ast.figure_out_scope(); | ||
@@ -255,0 +266,0 @@ ast.compute_char_frequency(); |
@@ -20,3 +20,3 @@ | ||
var urlObject = url.parse(urlStr), base; | ||
var urlObject = url.parse(urlStr, true), base; | ||
@@ -30,3 +30,20 @@ base = parseUrl(urlObject.protocol + '//' + urlObject.host); | ||
/* | ||
Extracts the base from a url | ||
@api: private | ||
@param: (String) urlStr - a url | ||
@returns: url base | ||
*/ | ||
function isHttps(urlStr) { | ||
"use strict"; | ||
var protocol = url.parse(urlStr, true).protocol; | ||
return (protocol === 'https:'); | ||
} | ||
/* | ||
@@ -42,3 +59,3 @@ Extracts a pathname from a url | ||
var urlObject = url.parse(urlStr), pathname, ext; | ||
var urlObject = url.parse(urlStr, true), pathname, ext; | ||
@@ -138,2 +155,3 @@ pathname = urlObject.pathname; | ||
module.exports.parseUrl = parseUrl; | ||
module.exports.isHttps = isHttps; | ||
{ | ||
"name": "crushit", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "CrushIt is a commandline tool for crawling web pages and compiling scripts", | ||
@@ -5,0 +5,0 @@ "homepage": "http://qawemlilo.github.io/crushit/", |
@@ -0,0 +0,0 @@ # CrushIt |
@@ -0,0 +0,0 @@ var q = null; |
@@ -0,0 +0,0 @@ |
@@ -43,1 +43,12 @@ | ||
}); | ||
describe('#isHttps', function() { | ||
it('should extracts a pathname from a url', function() { | ||
var url_one = helper.isHttps('http://www.google.com'); | ||
var url_two = helper.isHttps('https://www.google.com'); | ||
url_one.should.be.false; | ||
url_two.should.be.true; | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45864
901
3