File tree 1 file changed +9
-3
lines changed
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) {
58
58
59
59
// check if relative links are valid
60
60
links && links . forEach ( link => {
61
- const filename = link
61
+ const shortname = link
62
62
. replace ( / # [ \w - ] * $ / , '' )
63
63
. replace ( / \. h t m l $ / , '.md' )
64
+ const filename = shortname
64
65
. replace ( / \/ $ / , '/README.md' )
65
66
. 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 ) ) ) {
68
74
this . emitWarning (
69
75
new Error (
70
76
`\nFile for relative link "${ link } " does not exist.\n` +
You can’t perform that action at this time.
0 commit comments