Skip to content

Commit

Permalink
fix: find uppercased notes when referenced with lowercase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zoni committed Jan 10, 2021
1 parent d330af3 commit e6fc611
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
})
}

Expand Down
2 changes: 2 additions & 0 deletions tests/testdata/expected/main-samples/obsidian-wikilinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]]`

````
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions tests/testdata/input/main-samples/obsidian-wikilinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]]`

```
Expand Down

0 comments on commit e6fc611

Please sign in to comment.