Skip to main content

suffixes

Function suffixes 

Source
pub fn suffixes(path_no_ext: &str) -> Vec<String>
Expand description

a/b/c -> ["c", "b/c", "a/b/c"].

Public for the same reason strip_md_ext and percent_decode are, and for one specific kind of caller: one that needs the candidate set behind a link target, which LinkIndex deliberately does not keep (it stores one winner per key, which is all resolution needs and all a whole-vault cache should pay for). A rename planner, for example, can build its own key → candidates multimap to answer “is this bare name still unambiguous after the move”. It must key that map exactly the way LinkIndex::build does or the two would disagree about what a link points at. Sharing this function and normalize_target makes that impossible.

§Examples

use markdown_link::suffixes;

assert_eq!(suffixes("a/b/c"), ["c", "b/c", "a/b/c"]);
assert_eq!(suffixes("c"), ["c"]);