Skip to content

Commit

Permalink
fix: relative link checking
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 27, 2018
1 parent 87e88f3 commit 31b8feb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/webpack/markdownLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function (src) {
// check if relative links are valid
links && links.forEach(link => {
const shortname = link
.replace(/#[\w-]*$/, '')
.replace(/#.*$/, '')
.replace(/\.html$/, '.md')
const filename = shortname
.replace(/\/$/, '/README.md')
Expand All @@ -69,7 +69,7 @@ module.exports = function (src) {
const dir = path.dirname(this.resourcePath)
const file = path.resolve(dir, filename)
const altfile = altname !== filename ? path.resolve(dir, altname) : null
if (!fs.existsSync(file) && (altfile && !fs.existsSync(altfile))) {
if (!fs.existsSync(file) && (!altfile || !fs.existsSync(altfile))) {
this.emitWarning(
new Error(
`\nFile for relative link "${link}" does not exist.\n` +
Expand Down

0 comments on commit 31b8feb

Please sign in to comment.