Skip to content

Commit

Permalink
Merge pull request #74 from jaygooby/master
Browse files Browse the repository at this point in the history
Strip single-line javascript comments from the html template before generation
  • Loading branch information
premasagar committed Apr 3, 2013
2 parents 9ab0944 + 31a88f6 commit 0d2ad79
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tools/build-crossdomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ function buildTemplate(html, widgetName, doStripwhitespace){
.replace(/(?=\n)/g, '\\'); // escape end of lines
}

// this is very dumb, as it only handles the most
// basic of cases - we'd need a full blown parser to cope
// with multiline quotes etc
function stripComments(txt) {
return txt
.replace(/\s+\/\/.*/g, ''); // strip quotes
}

html = escape(
doStripwhitespace ?
stripwhitespace(html) :
html
);
stripComments(
doStripwhitespace ?
stripwhitespace(html) :
html
));

if (!widgetName){
alert('No widget name provided');
Expand Down

0 comments on commit 0d2ad79

Please sign in to comment.