pub fn link_edge_key(canonical_target: &str) -> StringExpand description
The comparison key for a canonical link target. Two normalizations, applied in order, so the string-keyed edge comparison agrees with how the filesystem resolves the same link:
- Unicode NFC, always. macOS/APFS folds NFC and NFD forms of a name to
the same file, so a file
records/contacts/josé.mdwritten NFC (é= U+00E9) and a link[[records/contacts/josé]]written NFD (e+ U+0301) name the same file on disk — yet their raw UTF-8 bytes differ. Without normalization the graph keys them as two different targets, sobacklinks/forwardlinksmiss the edge andorphansflags a linked-to file as an orphan, whilevalidate(which resolves through the filesystem) sees the link as live: the surfaces silently disagree. Normalizing BOTH sides to NFC here makes the comparison normalization-insensitive, matching the filesystem. This lives in the comparison key — not incanonical_link_target— so the canonical form stays byte/normalization-preserving (rename REWRITE output is never silently re-normalized); both the link target and the file path pass through this function, so NFC here is sufficient to unify them. - ASCII case-fold on a case-insensitive filesystem. Identity on a
case-sensitive FS, ASCII-lowercased on macOS/Windows, so the comparison
also agrees with the filesystem’s case-folding
is_file()resolution.
Callers compare link_edge_key(a) == link_edge_key(b).