Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filename-reserved-regex

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filename-reserved-regex

Regular expression for matching reserved filename characters

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6M
increased by3.7%
Maintainers
1
Weekly downloads
 
Created

What is filename-reserved-regex?

The filename-reserved-regex npm package provides a regular expression that matches characters that are reserved in filenames across different operating systems. This can be particularly useful for validating filenames or sanitizing them to ensure they are compatible across Windows, macOS, and Unix/Linux systems.

What are filename-reserved-regex's main functionalities?

Validation of filenames

This code sample demonstrates how to use the package to check if a string (which is intended to be used as a filename) contains any reserved characters. The `match` method will return an array of matches if any reserved characters are found, or `null` if the filename is safe to use.

"some*filename?.txt".match(filenameReservedRegex())

Sanitization of filenames

This code sample shows how to sanitize a filename by removing any reserved characters. This is done by replacing any characters that match the regex provided by the package with an empty string, effectively removing them.

"some*filename?.txt".replace(filenameReservedRegex(), '')

Other packages similar to filename-reserved-regex

Keywords

FAQs

Package last updated on 16 Aug 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc