repairName
Repairs a name so that it satisfies every enabled platform.
The order is deliberate: characters are replaced and a reserved name de-reserved BEFORE anything is truncated, because both can change the length, and trailing dots and spaces are trimmed AFTER every cut, because a cut can expose new ones.
Truncation only ever shortens the basename — an extension is what tells Obsidian and the OS what the file is, so a truncated one turns a working .png into a broken .pn.
Import:
import { repairName } from '@mnaoumov/obsidian-lib/path-compatibility';Signature:
function repairName(params: RepairNameParams): string | nullParameters:
| Parameter | Type | Description |
|---|---|---|
params |
RepairNameParams | The name and the platforms it must satisfy. |
Returns: string | null — The repaired name, unchanged when it was already valid, or null when no name survives the repair — which is what the report calls out rather than failing silently.
Links to this page: