@@ -12,7 +12,7 @@ var path = require('path');
1212var slash = require ( 'slash' ) ;
1313
1414var STARTING_DELIMITER = '(\\\\?\'|\\\\?"|\\\\?\\()' ;
15- var ALLOWED_PATH_CHARS = '[^\'"\\(\\)\\?#]*?' ; // Lazy, in order not to eat the optional starting character of ENDING_DELIMITER
15+ var ALLOWED_PATH_CHARS = '( [^\'"\\(\\)\\?#]*?) ' ; // Lazy, in order not to eat the optional starting character of ENDING_DELIMITER
1616var ENDING_DELIMITER = '(\\\\?\'|\\\\?"|\\\\?\\)|\\?|#)' ;
1717
1818module . exports = function ( grunt ) {
@@ -29,9 +29,9 @@ module.exports = function(grunt) {
2929
3030 function filerev_summary_to_assets_paths ( assets_root ) {
3131 var assets = { } ;
32- for ( var path in grunt . filerev . summary ) {
33- var src = file_path_to_web_path ( path , assets_root ) ;
34- var dest = file_path_to_web_path ( grunt . filerev . summary [ path ] , assets_root ) ;
32+ for ( var filerev_path in grunt . filerev . summary ) {
33+ var src = file_path_to_web_path ( filerev_path , assets_root ) ;
34+ var dest = path . basename ( grunt . filerev . summary [ filerev_path ] ) ;
3535 var regexp = asset_path_regexp ( src ) ;
3636 assets [ src ] = { dest : dest , regexp : regexp } ;
3737 }
@@ -47,8 +47,10 @@ module.exports = function(grunt) {
4747
4848 function asset_path_regexp ( asset_path ) {
4949 return new RegExp ( STARTING_DELIMITER + // p1
50- '(' + ALLOWED_PATH_CHARS + escape_for_regexp ( path . basename ( asset_path ) ) + ALLOWED_PATH_CHARS + ')' + // p2
51- ENDING_DELIMITER , // p3
50+ ALLOWED_PATH_CHARS + // p2
51+ '(' + escape_for_regexp ( path . basename ( asset_path ) ) + ')' + // p3
52+ ALLOWED_PATH_CHARS + // p4
53+ ENDING_DELIMITER , // p5
5254 'ig' ) ;
5355 }
5456
@@ -60,12 +62,12 @@ module.exports = function(grunt) {
6062 var view = grunt . file . read ( view_src ) ;
6163 var changes = [ ] ;
6264
63- var replace_string = function ( match , p1 , p2 , p3 ) {
64- var asset_path = absolute_asset_path ( p2 , view_src , views_root ) ;
65+ var replace_string = function ( match , p1 , p2 , p3 , p4 , p5 ) {
66+ var asset_path = absolute_asset_path ( p2 + p3 + p4 , view_src , views_root ) ;
6567
6668 if ( grunt . file . arePathsEquivalent ( asset_path . toLowerCase ( ) , asset_src . toLowerCase ( ) ) ) {
6769 changed = true ;
68- return p1 + asset_dest + p3 ;
70+ return p1 + p2 + asset_dest + p4 + p5 ;
6971 } else {
7072 return match ;
7173 }
@@ -88,7 +90,7 @@ module.exports = function(grunt) {
8890
8991 function absolute_asset_path ( string , view_src , views_root ) {
9092 var asset_path = string . trim ( ) ;
91- if ( asset_path [ 0 ] != '/' && asset_path [ 0 ] != '\\' ) {
93+ if ( asset_path [ 0 ] !== '/' && asset_path [ 0 ] != = '\\' ) {
9294 asset_path = path . join ( path . dirname ( view_src ) , asset_path ) ;
9395 asset_path = file_path_to_web_path ( asset_path , views_root ) ;
9496 }
0 commit comments