2.1.2 • Published 1 year ago

@igor.dvlpr/unc-path v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

UNC Path

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

✨ 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: '',
      	}
*/
2.1.2

1 year ago

2.1.1

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago