Socket
Socket
Sign inDemoInstall

unc-path-regex

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unc-path-regex

Regular expression for testing if a file path is a windows UNC file path. Can also be used as a component of another regexp via the `.source` property.


Version published
Weekly downloads
6.1M
increased by1.64%
Maintainers
2
Weekly downloads
 
Created

What is unc-path-regex?

The unc-path-regex npm package provides a regular expression specifically designed to match UNC (Universal Naming Convention) paths. UNC paths are used to specify the location of resources like files or devices on a network. This package is particularly useful for developers working with network file systems in Node.js applications, allowing them to validate and manipulate UNC paths efficiently.

What are unc-path-regex's main functionalities?

UNC Path Validation

This feature allows developers to validate if a given string is a UNC path. The provided code sample demonstrates how to use the unc-path-regex to test if specific paths are UNC paths.

const uncPathRegex = require('unc-path-regex');
const regex = uncPathRegex();
console.log(regex.test('\\\\Server01\\user\\docs\\Letter.txt')); // true
console.log(regex.test('C:\\path\\to\\file.txt')); // false

Extract UNC Path Components

This feature can be used to extract components of a UNC path using the regex match method. The code sample shows how to extract the full UNC path from a string.

const uncPathRegex = require('unc-path-regex');
const regex = uncPathRegex();
const uncPath = '\\\\Server01\\share\\file.txt';
const match = uncPath.match(regex);
console.log(match[0]); // '\\\\Server01\\share\\file.txt'

Other packages similar to unc-path-regex

Keywords

FAQs

Package last updated on 10 Apr 2016

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