fix: find uppercased notes when referenced with lowercase

This commit fixes a bug where, if a note contained uppercase characters
(for example `Note.md`) but was referred to using lowercase
`(`[[note]]`), that note would not be found.
This commit is contained in:
Nick Groenen 2021-01-10 19:43:28 +01:00
parent d330af3989
commit e6fc611b58
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
4 changed files with 7 additions and 2 deletions

View File

@ -586,10 +586,11 @@ fn lookup_filename_in_vault<'a>(
// sentence even if the note is capitalized for example) so we also try a case-insensitive
// lookup.
vault_contents.iter().find(|path| {
let path_lowered = PathBuf::from(path.to_string_lossy().to_lowercase());
path.ends_with(&filename)
|| path.ends_with(&filename.to_lowercase())
|| path_lowered.ends_with(&filename.to_lowercase())
|| path.ends_with(format!("{}.md", &filename))
|| path.ends_with(format!("{}.md", &filename.to_lowercase()))
|| path_lowered.ends_with(format!("{}.md", &filename.to_lowercase()))
})
}

View File

@ -6,6 +6,8 @@ Link to [pure-markdown-examples > Heading 1](pure-markdown-examples.md#heading-1
Link to [pure markdown examples](pure-markdown-examples.md#heading-1).
Link to [uppercased-note](Uppercased-note.md).
Link within backticks: `[[pure-markdown-examples]]`
````

View File

View File

@ -6,6 +6,8 @@ Link to [[pure-markdown-examples#Heading 1]].
Link to [[pure-markdown-examples#Heading 1|pure markdown examples]].
Link to [[uppercased-note]].
Link within backticks: `[[pure-markdown-examples]]`
```