Skip to content

Commit

Permalink
Merge pull request #629 from sleeper/fixing_627
Browse files Browse the repository at this point in the history
Fixing #627
  • Loading branch information
sleeper committed Oct 13, 2012
2 parents 1f2502e + 72c1325 commit 081cf42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/tasks/usemin.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ module.exports = function(grunt) {
// //
grunt.registerHelper('replace', function(content, regexp) { grunt.registerHelper('replace', function(content, regexp) {
return content.replace(regexp, function(match, src) { return content.replace(regexp, function(match, src) {
//do not touch external files //do not touch external files or the root
if ( src.match(/\/\//) ) { if ( src.match(/\/\//) || src.match(/^\/$/)) {
return match; return match;
} }


Expand Down
16 changes: 16 additions & 0 deletions cli/test/test-usemin.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ describe('usemin', function() {
grunt.file.mkdir('images'); grunt.file.mkdir('images');
grunt.file.mkdir('css'); grunt.file.mkdir('css');
}); });

it('should skip external filei', function() {
grunt.file.write('images/23012.foo.png', "foo");
var content = '<img src="//css/main.css">';
var awaited = '<img src="//css/main.css">';
var changed = grunt.helper('usemin:post:html', content);
assert.ok( changed == awaited );

});


it('do not depend on tag position', function() { it('do not depend on tag position', function() {
grunt.file.write('css/23012.main.css', "foo"); grunt.file.write('css/23012.main.css', "foo");
Expand All @@ -79,6 +88,13 @@ describe('usemin', function() {
var changed = grunt.helper('usemin:post:html', content); var changed = grunt.helper('usemin:post:html', content);
assert.ok( changed == awaited ); assert.ok( changed == awaited );
}); });

it('should handle properly the case of the root path (/)', function() {
var content = '<a href="/">'
var awaited = '<a href="/">';
var changed = grunt.helper('usemin:post:html', content);
assert.ok( changed == awaited );
});
}); });
}); });


0 comments on commit 081cf42

Please sign in to comment.