Skip to content

Commit aba2363

Browse files
committed
fixing special case for index/ links
1 parent 9fb5e8c commit aba2363

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/helpers/pathIsValid.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const stripOffAnchorTags = require('./stripOffAnchorTags');
2-
const removeTrailingSlash = require('./removeTrailingSlash');
2+
const removeTrailingIndex = require('./removeTrailingIndex');
33
const removeMarkdownFileFromFilepath = require('./removeMarkdownFileFromFilepath');
44
const computeLinkRelativeToWorkingDir = require('./computeLinkRelativeToWorkingDir');
55
const handleImageEdgeCases = require('./handleImageEdgeCases');
@@ -22,7 +22,8 @@ module.exports = function pathIsValid(filepath, link) {
2222
}
2323

2424
const cleanedLink = stripOffAnchorTags(link);
25-
const cleanedFilepath = removeMarkdownFileFromFilepath(filepath);
25+
let cleanedFilepath = removeMarkdownFileFromFilepath(filepath);
26+
cleanedFilepath = removeTrailingIndex(cleanedFilepath);
2627

2728
let normalized = computeLinkRelativeToWorkingDir(cleanedFilepath, cleanedLink);
2829
normalized = handleImageEdgeCases(normalized, link);

test/helpers/removeTrailingIndex.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function (filepath) {
2+
// chops off whatever is after the final slash
3+
return filepath.replace(/index\/$/, '');
4+
};

0 commit comments

Comments
 (0)