Permalink
Browse files

Merge pull request #598 from sleeper/fixing_502

Fixed #502
  • Loading branch information...
2 parents fc8e04b + d8907b9 commit d136154110ac8870586ba2f106d9db45db2c585e @sleeper sleeper committed Oct 11, 2012
Showing with 15 additions and 2 deletions.
  1. +1 −2 cli/tasks/usemin.js
  2. +14 −0 cli/test/test-usemin.js
View
@@ -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);
@@ -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.