File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,19 @@ module.exports = function (src) {
5858
5959  // check if relative links are valid 
6060  links  &&  links . forEach ( link  =>  { 
61-     const  filename  =  link 
61+     const  shortname  =  link 
6262      . replace ( / # [ \w - ] * $ / ,  '' ) 
6363      . replace ( / \. h t m l $ / ,  '.md' ) 
64+     const  filename  =  shortname 
6465      . replace ( / \/ $ / ,  '/README.md' ) 
6566      . replace ( / ^ \/ / ,  sourceDir  +  '/' ) 
66-     const  file  =  path . resolve ( path . dirname ( this . resourcePath ) ,  filename ) 
67-     if  ( ! fs . existsSync ( file ) )  { 
67+     const  altname  =  shortname 
68+       . replace ( / \/ $ / ,  '/index.md' ) 
69+       . replace ( / ^ \/ / ,  sourceDir  +  '/' ) 
70+     const  dir  =  path . dirname ( this . resourcePath ) 
71+     const  file  =  path . resolve ( dir ,  filename ) 
72+     const  altfile  =  altname  !==  filename  ? path . resolve ( dir ,  altname )  : null 
73+     if  ( ! fs . existsSync ( file )  &&  ( altfile  &&  ! fs . existsSync ( altfile ) ) )  { 
6874      this . emitWarning ( 
6975        new  Error ( 
7076          `\nFile for relative link "${ link }   + 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments