Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #629 from sleeper/fixing_627

Fixing #627
  • Loading branch information...
commit 081cf42d717ed25807fe694750a1e9253acf3051 2 parents 1f2502e + 72c1325
@sleeper sleeper authored
Showing with 18 additions and 2 deletions.
  1. +2 −2 cli/tasks/usemin.js
  2. +16 −0 cli/test/test-usemin.js
View
4 cli/tasks/usemin.js
@@ -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
16 cli/test/test-usemin.js
@@ -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 );
+ });
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.