Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 526,555 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.