@igorskyflyer/unc-path
v3.1.0
Published
🥽 Provides ways of parsing UNC paths and checking whether they are valid. 🎱
Maintainers
Readme
📃 Table of Contents
🤖 Features
- 🌐 Detects UNC paths for both Windows and UNIX formats
- 🖥️ Extracts
serverandresourceparts with named capture groups - 📦 Returns a typed object with
serverandresourcekeys - 🧩 Simple API with
isValid()andparse()functions - ⚡ Lightweight, zero‑dependency implementation
- 🛡️ Handles empty or invalid inputs gracefully
- 🔍 Uses clear, maintainable regular expressions
- 📝 TypeScript types for strong, predictable usage
- 🔄 Reusable patterns for consistent path parsing
🕵🏼 Usage
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/unc-pathyarn add @igorskyflyer/unc-pathnpm i @igorskyflyer/unc-path🤹🏼 API
isValid() => returns whether the given path is a UNC one.
Signature
isValid(path): booleanParameters
path: string // a string that represents the path to process🗒️ Examples
import { isValid } from '@igorskyflyer/unc-path'
console.log(isValid('//ComputerName/SharedFolder/')) // returns true
console.log(isValid('//ComputerName/SharedFolder/file.mp4')) // returns true
console.log(isValid('/ComputerName/SharedFolder/')) // returns falseparse() => parses the provided UNC path and returns UNC path's components as
{
'server': string,
'resource': string
}Signature
parse(path): ObjectParameters
path: string // a string that represents the path to processExample
import { parse } from '@igorskyflyer/unc-path'
console.log(parse('//Server/Dev/file.js'))
/*
returns {
server: 'Server',
resource: '/Dev/file.js',
}
*/
console.log(parse('/Server/Dev/file.js'))
/*
returns {
server: '',
resource: '',
}
*/📝 Changelog
📑 The changelog is available here, CHANGELOG.md.
🪪 License
Licensed under the MIT license which is available here, MIT license.
💖 Support
🧬 Related
🏃♂️ Fast and simple Map and RegExp based HTML entities encoder. 🍁
📚 An NPM package for fetching Windows registry keys. 🗝
🎍 Provides a universal way of formatting file-paths in Unix-like and Windows operating systems as an alternative to the built-in path.normalize(). 🧬
🔼 Provides a way to check if the given path is the root drive/directory. ⛔
🧰 Provides ways of testing whether a given value can be a valid file/directory name. 🏜
👨🏻💻 Author
Created by Igor Dimitrijević (@igorskyflyer).
