Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
is-invalid-path
Advanced tools
The is-invalid-path npm package is a utility that helps determine if a given file path is invalid. It is useful for validating file paths in various environments and ensuring that paths conform to the expected format.
Basic Path Validation
This feature allows you to check if a given path is invalid. The function returns true if the path is invalid and false if it is valid.
const isInvalidPath = require('is-invalid-path');
const path1 = 'C:\invalid|path';
const path2 = '/valid/path';
console.log(isInvalidPath(path1)); // true
console.log(isInvalidPath(path2)); // false
Custom Invalid Characters
This feature allows you to specify custom invalid characters for path validation. The function will check the path against these custom characters and return true if the path contains any of them.
const isInvalidPath = require('is-invalid-path');
const customInvalidChars = ['*', '?', '<', '>', '|'];
const path1 = 'C:\invalid*path';
const path2 = '/valid/path';
console.log(isInvalidPath(path1, customInvalidChars)); // true
console.log(isInvalidPath(path2, customInvalidChars)); // false
The valid-path package is another alternative that checks for the validity of file paths. It focuses on ensuring that paths do not contain invalid characters and are properly formatted. It is similar to is-invalid-path but may have different rules for what constitutes an invalid path.
Returns true if a windows file path has invalid characters.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save is-invalid-path
const isInvalid = require('is-invalid-path');
// true if the path is not a string or has invalid characters
console.log(isInvalid()); //=> true
console.log(isInvalid('<abc')); //=> true
console.log(isInvalid('>abc')); //=> true
console.log(isInvalid(':abc')); //=> true
console.log(isInvalid('"abc')); //=> true
console.log(isInvalid('|abc')); //=> true
console.log(isInvalid('?abc')); //=> true
console.log(isInvalid('*abc')); //=> true
// true if the path has slashes and options.file is true,
// as slashes and backslashes are invalid in file names
console.log(isInvalid('foo/abc', { file: true })); //=> true
console.log(isInvalid('foo\\abc', { file: true })); //=> true
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
true
if the given string looks like a glob pattern or an extglob pattern… more | homepageJon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on April 19, 2018.
FAQs
Returns true if a windows file path has invalid characters.
The npm package is-invalid-path receives a total of 1,560,299 weekly downloads. As such, is-invalid-path popularity was classified as popular.
We found that is-invalid-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.