Skip to content

Commit c247429

Browse files
committed
fix md prefix bug in wiki-links on lookup
1 parent 4ef3822 commit c247429

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

md/test-presentation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Test-Duplicate
2+
A file with this name exists twice in the project. Only with a different path.
3+
So the wiki-links feature will add a path to it.
4+
5+
[[md/presentations/test-presentation|test-presentation]]

obsidian.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,16 @@ function preReplaceObsidianFileLinks(html, req) {
464464
alt = null;
465465
}
466466
}
467+
if (fileName.startsWith("/md/")) {
468+
fileName = fileName.slice(4);
469+
}
470+
if (fileName.startsWith("md/")) {
471+
fileName = fileName.slice(3);
472+
}
467473
const lastPartOfFileName = fileName.split("/").pop();
468474
const filePath = mdFilesMap[lastPartOfFileName];
475+
console.log(fileName)
476+
console.log(mdFilesMap)
469477
if (filePath) {
470478
let f = filePath[0];
471479
if (filePath.length > 1) {
@@ -658,6 +666,12 @@ function replaceObsidianImageLinks(html, req) {
658666
if (r) {
659667
fileName = r.name;
660668
}
669+
if (fileName.startsWith("/md/")) {
670+
fileName = fileName.slice(4);
671+
}
672+
if (fileName.startsWith("md/")) {
673+
fileName = fileName.slice(3);
674+
}
661675
const lastPartOfFileName = fileName.split("/").pop();
662676
const filePath = filesMap[lastPartOfFileName];
663677
if (filePath) {

0 commit comments

Comments
 (0)