Skip to content

getOsUnsafePathCharsRegExp

Returns a regexp matching the characters Obsidian refuses in a file name on the given platform.

That is WINDOWS_UNSAFE_PATH_CHARS on Windows, ANDROID_UNSAFE_PATH_CHARS on Android and UNIX_UNSAFE_PATH_CHARS everywhere else. It is Obsidian’s set rather than the file system’s, so a name it accepts can be created through the vault.

Import:

import { getOsUnsafePathCharsRegExp } from '@mnaoumov/obsidian-lib/validation';

Signature:

function getOsUnsafePathCharsRegExp(isWindows: boolean | undefined, isAndroid: boolean | undefined): RegExp

Parameters:

Parameter Type Description
isWindows boolean | undefined Whether to use the Windows character set. Defaults to Platform.isWin.
isAndroid boolean | undefined Whether to use the Android character set when isWindows is false. Defaults to Platform.isAndroidApp.

Returns: RegExp — A regexp matching the characters Obsidian refuses in a file name on the given platform.


Links to this page: