Skip to content

Commit

Permalink
Merge pull request #598 from sleeper/fixing_502
Browse files Browse the repository at this point in the history
Fixed #502
  • Loading branch information
sleeper committed Oct 11, 2012
2 parents fc8e04b + d8907b9 commit d136154
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cli/tasks/usemin.js
Expand Up @@ -325,12 +325,11 @@ module.exports = function(grunt) {
// usemin:post:* are the global replace handlers, they delegate the regexp
// replace to the replace helper.
grunt.registerHelper('usemin:post:html', function(content) {

grunt.log.verbose.writeln('Update the HTML to reference our concat/min/revved script files');
content = grunt.helper('replace', content, /<script.+src=['"](.+)["'][\/>]?><[\\]?\/script>/gm);

grunt.log.verbose.writeln('Update the HTML with the new css filenames');
content = grunt.helper('replace', content, /<link rel=["']?stylesheet["']?\shref=['"](.+)["']\s*\/?>/gm);
content = grunt.helper('replace', content, /<link[^\>]+href=['"]([^"']+)["']/gm);

grunt.log.verbose.writeln('Update the HTML with the new img filenames');
content = grunt.helper('replace', content, /<img[^\>]+src=['"]([^"']+)["']/gm);
Expand Down
14 changes: 14 additions & 0 deletions cli/test/test-usemin.js
Expand Up @@ -47,5 +47,19 @@ describe('usemin', function() {
assert.ok( changed == awaited );
});
});

describe('usemin:post:html', function() {
it('do not depend on tag position', function() {
usemin.call(grunt,grunt);
grunt.log.muted = true;
grunt.file.mkdir('css');
grunt.file.write('css/23012.main.css', "foo");
var content = '<link href="css/main.css" rel="stylesheet"/><link rel="stylesheet" href="css/main.css"/>';
var awaited = '<link href="css/23012.main.css" rel="stylesheet"/><link rel="stylesheet" href="css/23012.main.css"/>';
var changed = grunt.helper('usemin:post:html', content);
grunt.log.writeln("FRED: ["+content+"]["+changed+"]");
assert.ok( changed == awaited );
});
});
});

0 comments on commit d136154

Please sign in to comment.