Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
--csp will now operate on the input html file as well
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jan 8, 2014
1 parent 388b5a5 commit 32c32c7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/vulcan.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ function handleMainDocument() {
}
var scripts = [];
var scripts_after_polymer = [];
var tempoutput = cheerio.load(output);

tempoutput('script').each(function() {
var fn = function() {
var src = this.attr('src');
if (src) {
// external script
Expand All @@ -293,8 +292,16 @@ function handleMainDocument() {
// inline script
scripts.push(this.text());
}
}).remove();
};

// CSPify imports
var tempoutput = cheerio.load(output);
tempoutput('script').each(fn).remove();
output = tempoutput.html();

// CSPify main page
$('script').each(fn).remove();

// join scripts with ';' to prevent breakages due to EOF semicolon insertion
var script_name = path.basename(options.output, '.html') + '.js';
fs.writeFileSync(path.resolve(options.outputDir, script_name), scripts.join(';' + EOL), 'utf8');
Expand Down

0 comments on commit 32c32c7

Please sign in to comment.