Resolve "normal links" without a file extension

This is against the markdown spec, but the foam documentaiton seem to
have this in a number of places.
This commit is contained in:
Vishesh Handa
2020-09-14 17:41:53 +02:00
parent d2326658d4
commit a28fc308c0
2 changed files with 14 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class LinkResolver {
assert(l.filePath.startsWith(rootFolder.folderPath));
var spec = l.filePath.substring(rootFolder.folderPath.length + 1);
return rootFolder.getNoteWithSpec(spec);
return _getNoteWithSpec(rootFolder, spec);
}
Note resolve(String link) {

View File

@ -168,6 +168,19 @@ void main() {
expect(resolvedNote.filePath, expectedNote.filePath);
});
test('Should resolve Link object without extension', () {
var note = rootFolder.getNoteWithSpec('Folder/Water.md');
var linkResolver = LinkResolver(note);
var expectedNote = rootFolder.getNoteWithSpec('Fire.md');
var filePath = expectedNote.filePath;
filePath = filePath.substring(0, filePath.length - 3);
var link = Link(filePath: filePath, publicTerm: 'foo');
var resolvedNote = linkResolver.resolveLink(link);
expect(resolvedNote.filePath, expectedNote.filePath);
});
test('Should resolve Wiki Link object', () {
var note = rootFolder.getNoteWithSpec('Folder/Water.md');
var linkResolver = LinkResolver(note);