Skip to content

isWindowsReservedName

Checks whether a name is one of the MS-DOS device names Windows refuses.

Two steps the caller would otherwise have to know about happen here: trailing dots and spaces are trimmed BEFORE the test, because Windows strips them before deciding and CON is therefore as reserved as CON; and the extension is dropped, because CON.md is reserved too.

CONIN$ / CONOUT$ and the superscript COM² forms are deliberately NOT reserved: they are accepted by every Windows version that runs Obsidian, and matching them would rename files that work.

Answers for Windows regardless of the platform in use: a vault is synced, so the rules that matter are not necessarily those of the machine asking.

Import:

import { isWindowsReservedName } from 'obsidian-dev-utils/obsidian/validation';

Signature:

function isWindowsReservedName(name: string): boolean

Parameters:

ParameterTypeDescription
namestringThe name to check. A single path segment, with or without its extension.

Returns: booleantrue if the name is reserved, false otherwise.


Links to this page: