diff --git a/tasks/inline.js b/tasks/inline.js index 5e08f6d..4138fc7 100644 --- a/tasks/inline.js +++ b/tasks/inline.js @@ -73,7 +73,7 @@ module.exports = function(grunt) { filepath = filepath.replace(/[^\/]+\//, relativeTo); } - fileContent = fileContent.replace(//g, function(matchedWord, src){ + fileContent = fileContent.replace(/]+?src=["']([^"']+?)["']\s*?\/>/g, function(matchedWord, src){ var ret = matchedWord; if(isRemotePath(src) || !grunt.file.isPathAbsolute(src)){ @@ -93,7 +93,7 @@ module.exports = function(grunt) { } return _ret; } - ret = ret.replace(/(<\/script>)/g,_addMore); + ret = ret.replace(/(]+?src=["'])([^"']+?)(["'].*?><\/script>)/g,_addMore); } }else{ grunt.log.error("Couldn't find " + inlineFilePath + '!'); @@ -101,7 +101,7 @@ module.exports = function(grunt) { } return ret; - }).replace(/\s*<\/script>/g, function(matchedWord, src){ + }).replace(/]+?src=["']([^"']+?)["'].*?>\s*<\/script>/g, function(matchedWord, src){ var ret = matchedWord; if(!isRemotePath(src) && src.indexOf(options.tag)!=-1){ @@ -118,7 +118,7 @@ module.exports = function(grunt) { return ret; - }).replace(//g, function(matchedWord, src){ + }).replace(/]+?href=["']([^"']+?)["'].*?\/?>/g, function(matchedWord, src){ var ret = matchedWord; if(!isRemotePath(src) && src.indexOf(options.tag)!=-1){ @@ -136,7 +136,7 @@ module.exports = function(grunt) { grunt.log.debug('ret = : ' + ret +'\n'); return ret; - }).replace(//g, function(matchedWord, src){ + }).replace(/]+?src=["']([^"':]+?)["'].*?\/?\s*?>/g, function(matchedWord, src){ var ret = matchedWord; if(!grunt.file.isPathAbsolute(src) && src.indexOf(options.tag)!=-1){ diff --git a/test/dist/script_greedy.html b/test/dist/script_greedy.html index b29fc60..8fed0a1 100644 --- a/test/dist/script_greedy.html +++ b/test/dist/script_greedy.html @@ -2,7 +2,7 @@ test - + diff --git a/test/expected/script_greedy.min.html b/test/expected/script_greedy.min.html index 9a49bd9..d6f403d 100644 --- a/test/expected/script_greedy.min.html +++ b/test/expected/script_greedy.min.html @@ -1 +1 @@ -test \ No newline at end of file +test \ No newline at end of file