@@ -11,6 +11,12 @@ var REGEXP_HASH = /\[hash(?::(\d+))?\]/gi,
1111 REGEXP_QUERY = / \[ q u e r y \] / gi,
1212 REGEXP_FILEBASE = / \[ f i l e b a s e \] / gi;
1313
14+ // Using global RegExp for .test is dangerous
15+ // We use a normal RegExp instead of .test
16+ var REGEXP_HASH_FOR_TEST = new RegExp ( REGEXP_HASH . source , "i" ) ,
17+ REGEXP_CHUNKHASH_FOR_TEST = new RegExp ( REGEXP_CHUNKHASH . source , "i" ) ,
18+ REGEXP_NAME_FOR_TEST = new RegExp ( REGEXP_NAME . source , "i" ) ;
19+
1420// Backwards compatibility; expose regexes on Template object
1521var Template = require ( "./Template" ) ;
1622Template . REGEXP_HASH = REGEXP_HASH ;
@@ -79,13 +85,13 @@ TemplatedPathPlugin.prototype.apply = function(compiler) {
7985 var publicPath = outputOptions . publicPath || "" ;
8086 var filename = outputOptions . filename || "" ;
8187 var chunkFilename = outputOptions . chunkFilename || "" ;
82- if ( REGEXP_HASH . test ( publicPath ) || REGEXP_CHUNKHASH . test ( publicPath ) || REGEXP_NAME . test ( publicPath ) )
88+ if ( REGEXP_HASH_FOR_TEST . test ( publicPath ) || REGEXP_CHUNKHASH_FOR_TEST . test ( publicPath ) || REGEXP_NAME_FOR_TEST . test ( publicPath ) )
8389 return true ;
84- if ( REGEXP_HASH . test ( filename ) )
90+ if ( REGEXP_HASH_FOR_TEST . test ( filename ) )
8591 return true ;
86- if ( REGEXP_HASH . test ( chunkFilename ) || REGEXP_CHUNKHASH . test ( chunkFilename ) || REGEXP_NAME . test ( chunkFilename ) )
92+ if ( REGEXP_HASH_FOR_TEST . test ( chunkFilename ) || REGEXP_CHUNKHASH_FOR_TEST . test ( chunkFilename ) || REGEXP_NAME_FOR_TEST . test ( chunkFilename ) )
8793 return true ;
88- if ( REGEXP_HASH . test ( paths . join ( "|" ) ) )
94+ if ( REGEXP_HASH_FOR_TEST . test ( paths . join ( "|" ) ) )
8995 return true ;
9096 } ) ;
9197 } ) ;
0 commit comments