@@ -96,7 +96,7 @@ function getAlias(loader, canonicalName) {
9696 bestAliasSubpath = '' ;
9797 bestAliasLength = alias . split ( '/' ) . length ;
9898 }
99- else if ( canonicalName . substr ( 0 , mapped . length ) == mapped &&
99+ else if ( canonicalName . substr ( 0 , mapped . length ) == mapped &&
100100 ( canonicalName . length == mapped . length || canonicalName [ mapped . length ] == '/' ) ) {
101101 bestAlias = alias ;
102102 bestAliasSubpath = canonicalName . substr ( mapped . length ) ;
@@ -189,7 +189,7 @@ function getCanonicalNamePlain(loader, normalized, isPlugin) {
189189
190190 // support trailing / in paths rules
191191 else if ( curPath [ curPath . length - 1 ] == '/' &&
192- normalized . substr ( 0 , curPath . length - 1 ) == curPath . substr ( 0 , curPath . length - 1 ) &&
192+ normalized . substr ( 0 , curPath . length - 1 ) == curPath . substr ( 0 , curPath . length - 1 ) &&
193193 ( normalized . length < curPath . length || normalized [ curPath . length - 1 ] == curPath [ curPath . length - 1 ] ) ) {
194194 // first case is that canonicalize('src') = 'app' for 'app/': 'src/'
195195 return normalized . length < curPath . length ? p . substr ( 0 , p . length - 1 ) : p + normalized . substr ( curPath . length ) ;
@@ -244,8 +244,7 @@ function createPkgConfigPathObj(path) {
244244 var length = Math . max ( lastWildcard + 1 , path . lastIndexOf ( '/' ) ) ;
245245 return {
246246 length : length ,
247- // NB handle regex control character escapes or simply create a test function here
248- regEx : new RegExp ( '^(' + path . substr ( 0 , length ) . replace ( / \* / g, '[^\\/]+' ) + ')(\\/|$)' ) ,
247+ regEx : new RegExp ( '^(' + path . substr ( 0 , length ) . replace ( / [ . + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) . replace ( / \* / g, '[^\\/]+' ) + ')(\\/|$)' ) ,
249248 wildcard : lastWildcard != - 1
250249 } ;
251250}
@@ -373,4 +372,3 @@ exports.serializeCondition = serializeCondition;
373372function serializeCondition ( conditionObj ) {
374373 return conditionObj . module + '|' + ( conditionObj . negate ? '~' : '' ) + conditionObj . prop ;
375374}
376-
0 commit comments