Skip to content

Commit 31b8feb

Browse files
committed
fix: relative link checking
1 parent 87e88f3 commit 31b8feb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/webpack/markdownLoader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function (src) {
5858
// check if relative links are valid
5959
links && links.forEach(link => {
6060
const shortname = link
61-
.replace(/#[\w-]*$/, '')
61+
.replace(/#.*$/, '')
6262
.replace(/\.html$/, '.md')
6363
const filename = shortname
6464
.replace(/\/$/, '/README.md')
@@ -69,7 +69,7 @@ module.exports = function (src) {
6969
const dir = path.dirname(this.resourcePath)
7070
const file = path.resolve(dir, filename)
7171
const altfile = altname !== filename ? path.resolve(dir, altname) : null
72-
if (!fs.existsSync(file) && (altfile && !fs.existsSync(altfile))) {
72+
if (!fs.existsSync(file) && (!altfile || !fs.existsSync(altfile))) {
7373
this.emitWarning(
7474
new Error(
7575
`\nFile for relative link "${link}" does not exist.\n` +

0 commit comments

Comments
 (0)