Comparing version 0.2.1 to 0.2.2
@@ -49,3 +49,3 @@ var less = require('less'), fs = require('fs'), diveSync = require("diveSync"); | ||
function stripLessJS(contents) { | ||
return contents.replace(/<script.*?less\.js.*?<\/script>/g, ""); | ||
return contents.replace(/<script.*?\bless\b[^"']*?\.js.*?<\/script>/g, ""); | ||
} | ||
@@ -52,0 +52,0 @@ |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -68,3 +68,19 @@ var buster = require('buster') | ||
}); | ||
it('should remove versioned and compressed "less" script tags', function() { | ||
var html = "<script src='js/lib/less-1.2.1.min.js'></script>"; | ||
expect(html).toMatch(/js\/lib\/less-1\.2\.1\.min.js/); | ||
//shouldn't strip it out | ||
var newHTML = lessless.stripLessJS(html); | ||
expect(newHTML).not().toMatch(/js\/lib\/less-1\.2\.1\.min.js/); | ||
expect(newHTML).not().toMatch(/script/); | ||
}); | ||
it('should not match scripts where "less" is not a standalone word', function() { | ||
var html = "<script src='js/lib/boundless.js'></script>"; | ||
expect(html).toMatch(/js\/lib\/boundless.js/); | ||
//shouldn't strip it out | ||
var newHTML = lessless.stripLessJS(html); | ||
expect(newHTML).toMatch(/js\/lib\/boundless.js/); | ||
}); | ||
}); | ||
}); |
48475
19
155