
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
is-valid-path
Advanced tools
Returns true if a file path does not contain any invalid characters.
The is-valid-path npm package is a utility for checking if a given string is a valid file path. It helps in validating paths to ensure they conform to the expected format and can be used in various file system operations.
Basic Path Validation
This feature allows you to check if a given string is a valid file path. It returns true for valid paths and false for invalid ones.
const isValidPath = require('is-valid-path');
console.log(isValidPath('valid/path/to/file.txt')); // true
console.log(isValidPath('invalid|path')); // false
Cross-Platform Path Validation
This feature ensures that the path validation works across different operating systems, including Windows and Unix-based systems.
const isValidPath = require('is-valid-path');
console.log(isValidPath('C:\valid\path\to\file.txt')); // true on Windows
console.log(isValidPath('/valid/path/to/file.txt')); // true on Unix-based systems
The valid-path package is another alternative that checks for valid file paths. It focuses on simplicity and ease of use, providing a straightforward API for path validation.
Returns true if a file path does not contain any invalid characters.
Install with npm
npm i is-valid-path --save
var isValid = require('is-valid-path');
/**
* Valid
*/
isValid('abc.js');
//=> 'true'
isValid('abc/def/ghi.js');
//=> 'true'
isValid('foo.js');
//=> 'true'
/**
* Invalid
*/
isValid();
//=> 'valse'
isValid(null);
//=> 'valse'
isValid('!foo.js');
//=> 'false'
isValid('*.js');
//=> 'false'
isValid('**/abc.js');
//=> 'false'
isValid('abc/*.js');
//=> 'false'
isValid('abc/(aaa|bbb).js');
//=> 'false'
isValid('abc/[a-z].js');
//=> 'false'
isValid('abc/{a,b}.js');
//=> 'false'
isValid('abc/?.js');
//=> 'false'
true
if the given string looks like a glob pattern.Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on May 06, 2015.
FAQs
Returns true if a file path does not contain any invalid characters.
The npm package is-valid-path receives a total of 911,451 weekly downloads. As such, is-valid-path popularity was classified as popular.
We found that is-valid-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.