@igor.dvlpr/unc-path
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

UNC Path

🥽 Provides ways of parsing UNC paths and checking whether they are valid. 🎱


UNC Path



💖 Support further development

Donate to igorskyflyer


Since version 2.0.0 unc-path is a hybrid module that supports both CommonJS (legacy) and ES modules, thanks to Modern Module.


Usage


Install it first by doing

npm i @igor.dvlpr/unc-path

and call require in your code, i.e.:

const unc = require('@igor.dvlpr/unc-path')
// or destructure the object and import only needed function(s)
// e.g.
const { isValid } = require('@igor.dvlpr/unc-path')

// do something cool with it

API


isValid() => returns whether the given path is a UNC one.


Signature

isValid(path): boolean

Parameters

path: string // a string that represents the path to process

Example

const { isValid } = require('@igor.dvlpr/unc-path')

console.log(isValid('//ComputerName/SharedFolder/')) // returns true
console.log(isValid('//ComputerName/SharedFolder/file.mp4')) // returns true
console.log(isValid('/ComputerName/SharedFolder/')) // returns false


parse() => parses the provided UNC path and returns UNC path's components as

{
	'server': string,
	'resource': string
}

Signature

parse(path): Object

Parameters

path: string // a string that represents the path to process

Example

const { parse } = require('@igor.dvlpr/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: '',
      	}
*/

Package Sidebar

Install

npm i @igor.dvlpr/unc-path

Weekly Downloads

15

Version

2.1.2

License

MIT

Unpacked Size

6.4 kB

Total Files

7

Last publish

Collaborators

  • igor.dvlpr