Permalink
Browse files

Fixing #627

  • Loading branch information...
1 parent 1f2502e commit 72c13253e7872f5134b7aff39dbdc526b0d3ed7c @sleeper committed Oct 13, 2012
Showing with 18 additions and 2 deletions.
  1. +2 −2 cli/tasks/usemin.js
  2. +16 −0 cli/test/test-usemin.js
View
@@ -358,8 +358,8 @@ module.exports = function(grunt) {
//
grunt.registerHelper('replace', function(content, regexp) {
return content.replace(regexp, function(match, src) {
- //do not touch external files
- if ( src.match(/\/\//) ) {
+ //do not touch external files or the root
+ if ( src.match(/\/\//) || src.match(/^\/$/)) {
return match;
}
View
@@ -55,6 +55,15 @@ describe('usemin', function() {
grunt.file.mkdir('images');
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() {
grunt.file.write('css/23012.main.css', "foo");
@@ -79,6 +88,13 @@ describe('usemin', function() {
var changed = grunt.helper('usemin:post:html', content);
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 72c1325

Please sign in to comment.