Skip to content

toValidFilePath

Requires a Node.js runtime ('qsu/node')

Remove invalid or unnecessary characters in the path.

Parameters

NameTypeRequiredDefault
filePathstring
isWindowsnamedboolean
Whether the target operating system to be checked is Windows

named parameters are passed as named parameters in Dart and keyword arguments in Python.

Returns

string

Examples

javascript
toValidFilePath('C:\\Windows\\System32\\', true); // 'C:\Windows\System32'
toValidFilePath('home/user/.bashrc'); // '/home/user/.bashrc'
dart
toValidFilePath('C:\\Windows\\System32\\', isWindows: true); // 'C:\Windows\System32'
toValidFilePath('home/user/.bashrc'); // '/home/user/.bashrc'
python
toValidFilePath('C:\\Windows\\System32\\', True) # 'C:\Windows\System32'
toValidFilePath('home/user/.bashrc') # '/home/user/.bashrc'

Released under the MIT License