@@ -23,9 +23,9 @@ export class RouterParserUtil {
2323 private cleanModulesTree ;
2424 private modulesWithRoutes = [ ] ;
2525 private transformAngular8ImportSyntax =
26- / ( [ ' " ] l o a d C h i l d r e n [ ' " ] : ) \( \) ( : [ ^ ) ] + ?) ? = > " i m p o r t \( ( \\ ' | ' | " ) ( [ ^ ' " ] + ?) ( \\ ' | ' | " ) \) \. t h e n \( \( ? \w + ?\) ? = > \S + ?\. ( [ ^ ) ] + ?) \) ( \\ ' | ' | " ) / g;
26+ / ( [ ' " ] l o a d C h i l d r e n [ ' " ] : ) \( \) ( : [ ^ ) ] + ?) ? = > " i m p o r t \( ( \\ ' | ' | " | ` ) ( [ ^ ' " ] + ?) ( \\ ' | ' | " | ` ) \) \. t h e n \( \( ? \w + ?\) ? = > \S + ?\. ( [ ^ ) ] + ?) \) ( \\ ' | ' | " ) / g;
2727 private transformAngular8ImportSyntaxAsyncAwait =
28- / ( [ ' " ] l o a d C h i l d r e n [ ' " ] : ) \( \) ( : [ ^ ) ] + ?) ? = > \( " i m p o r t \( ( \\ ' | ' | " ) ( [ ^ ' " ] + ?) ( \\ ' | ' | " ) \) " \) \. [ ' " ] ( [ ^ ) ] + ?) [ ' " ] / g;
28+ / ( [ ' " ] l o a d C h i l d r e n [ ' " ] : ) \( \) ( : [ ^ ) ] + ?) ? = > \( " i m p o r t \( ( \\ ' | ' | " | ` ) ( [ ^ ' " ] + ?) ( \\ ' | ' | " | ` ) \) " \) \. [ ' " ] ( [ ^ ) ] + ?) [ ' " ] / g;
2929
3030 private static instance : RouterParserUtil ;
3131 private constructor ( ) { }
@@ -594,8 +594,7 @@ export class RouterParserUtil {
594594
595595 if ( foundWithAliasInImports ) {
596596 if ( typeof searchedImport !== 'undefined' ) {
597-
598- const routePathIsBad = ( path ) => {
597+ const routePathIsBad = path => {
599598 return typeof ast . getSourceFile ( path ) == 'undefined' ;
600599 } ;
601600
@@ -604,7 +603,9 @@ export class RouterParserUtil {
604603 if ( searchStrLen == 0 ) {
605604 return [ ] ;
606605 }
607- var startIndex = 0 , index , indices = [ ] ;
606+ var startIndex = 0 ,
607+ index ,
608+ indices = [ ] ;
608609 if ( ! caseSensitive ) {
609610 str = str . toLowerCase ( ) ;
610611 searchStr = searchStr . toLowerCase ( ) ;
@@ -614,22 +615,28 @@ export class RouterParserUtil {
614615 startIndex = index + searchStrLen ;
615616 }
616617 return indices ;
617- }
618+ } ;
618619
619620 const dirNamePath = path . dirname ( file . getFilePath ( ) ) ;
620621 const searchedImportPath = searchedImport . getModuleSpecifierValue ( ) ;
621622 const leadingFilePath = searchedImportPath . split ( '/' ) . shift ( ) ;
622623
623- let importPath = path . resolve ( dirNamePath + '/' + searchedImport . getModuleSpecifierValue ( ) + '.ts' ) ;
624+ let importPath = path . resolve (
625+ dirNamePath + '/' + searchedImport . getModuleSpecifierValue ( ) + '.ts'
626+ ) ;
624627
625628 if ( routePathIsBad ( importPath ) ) {
626629 let leadingIndices = getIndicesOf ( leadingFilePath , importPath , true ) ;
627- if ( leadingIndices . length > 1 ) { // Nested route fixes
630+ if ( leadingIndices . length > 1 ) {
631+ // Nested route fixes
628632 let startIndex = leadingIndices [ 0 ] ;
629- let endIndex = leadingIndices [ leadingIndices . length - 1 ] ;
630- importPath = importPath . slice ( 0 , startIndex ) + importPath . slice ( endIndex ) ;
631- } else { // Top level route fixes
632- importPath = path . dirname ( dirNamePath ) + '/' + searchedImportPath + '.ts' ;
633+ let endIndex = leadingIndices [ leadingIndices . length - 1 ] ;
634+ importPath =
635+ importPath . slice ( 0 , startIndex ) + importPath . slice ( endIndex ) ;
636+ } else {
637+ // Top level route fixes
638+ importPath =
639+ path . dirname ( dirNamePath ) + '/' + searchedImportPath + '.ts' ;
633640 }
634641 }
635642 const sourceFileImport =
0 commit comments