fspvr v1.0.7
fspvr - Cross-Platform filesystem path validator and reformer
fspvr is a cross-platform filesystem validator and reformer which gets rid of illegal trailing or in-between characters and preserved words.
Table of contents
Reformat
var fspvr = require('fspvr');
var reformatedPath = fspvr.reformatPath('C:\\Windows?\\<System32>\\ntdll.dll', true);
console.log(reformatedPath); // C:\Windows\System32\ntdll.dllThe 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); // WindowsThe second parameter is for strict reformation as described above.
Validate
var fspvr = require('fspvr');
var isValidPath = fspvr.validatePath('C:\\Windows?\\<System32>\\ntdll.dll', true);
console.log(isValidPath); // falseThe 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); // trueThe second parameter is for strict validation as described above.
Tests
Run tests with
$ npm run test
License
fspvr is licensed under the GPL V3 License.
