@@ -2768,12 +2768,18 @@ QString Note::getFullFilePathForFile(const QString &fileName) {
27682768 return canonicalFilePath;
27692769}
27702770
2771- QString Note::getFilePathRelativeToNote (const Note ¬e, const QString &connectionName) const {
2772- const QDir dir (fullNoteFilePath (connectionName));
2771+ QString Note::getFilePathRelativeToNote (const Note ¬e, const QString &connectionName,
2772+ bool resolveFileSystemPaths) const {
2773+ const QDir dir (resolveFileSystemPaths
2774+ ? fullNoteFilePath (connectionName)
2775+ : relativeNoteFilePath (QStringLiteral (" /" ), connectionName));
27732776
27742777 // for some reason there is a leading "../" too much
27752778 static const QRegularExpression re (QStringLiteral (R"( ^\.\.\/)" ));
2776- QString path = dir.relativeFilePath (note.fullNoteFilePath (connectionName)).remove (re);
2779+ const QString notePath = resolveFileSystemPaths
2780+ ? note.fullNoteFilePath (connectionName)
2781+ : note.relativeNoteFilePath (QStringLiteral (" /" ), connectionName);
2782+ QString path = dir.relativeFilePath (notePath).remove (re);
27772783
27782784 // if "note" is the current note we want to use the real filename
27792785 if (path == QChar (' .' )) {
@@ -4737,7 +4743,8 @@ QVector<int> Note::findBacklinkedNoteIds(const QString &connectionName) const {
47374743 continue ;
47384744 }
47394745
4740- const QString relativePathToNote = note.getFilePathRelativeToNote (*this , connectionName);
4746+ const QString relativePathToNote =
4747+ note.getFilePathRelativeToNote (*this , connectionName, false );
47414748
47424749 // We now don't escape slashes in the relative file path, but previously we did,
47434750 // so we need to search for both
@@ -5054,7 +5061,8 @@ QHash<Note, QSet<LinkHit>> Note::findReverseLinkNotes(const QString &connectionN
50545061 continue ;
50555062 }
50565063
5057- const QString relativePathToNote = note.getFilePathRelativeToNote (*this , connectionName);
5064+ const QString relativePathToNote =
5065+ note.getFilePathRelativeToNote (*this , connectionName, false );
50585066
50595067 // Search legacy note:// protocol links
50605068 addTextToBacklinkNoteHashIfFound (note, QStringLiteral (" <" ) + noteUrl + QStringLiteral (" >" ));
0 commit comments