fspvr is a cross-platform filesystem validator and reformer which gets rid of illegal trailing or in-between characters and preserved words.
var fspvr = require('fspvr');
var reformatedPath = fspvr.reformatPath('C:\\Windows?\\<System32>\\ntdll.dll', true);
console.log(reformatedPath); // C:\Windows\System32\ntdll.dll
The second parameter is optional and defaults to true.
Its responisible for strict
reformation, meaning it will remove illegal trailing characters or preserved words.
Optinally, you can reformat only a segment in a path
var fspvr = require('fspvr');
var reformatedSegment = fspvr.reformatSegment('Windows?', true);
console.log(reformatedSegment); // Windows
The second parameter is for strict
reformation as described above.
var fspvr = require('fspvr');
var isValidPath = fspvr.validatePath('C:\\Windows?\\<System32>\\ntdll.dll', true);
console.log(isValidPath); // false
The second parameter is optional and defaults to true.
Its responisible for strict
validation, meaning it will validates againts illegal characters as-well as to illegal trailing characters or preserved words.
Optinally, you can validate only a segment in a path
var fspvr = require('fspvr');
var isValidSegment = fspvr.validateSegment('Windows', true);
console.log(isValidSegment); // true
The second parameter is for strict
validation as described above.
Run tests with
$ npm run test
fspvr is licensed under the GPL V3 License.