@igor.dvlpr/unc-path v3.0.0
UNC Path
π₯½ Provides ways of parsing UNC paths and checking whether they are valid. π±
π΅πΌ Usage
Install it by executing:
npm i "@igor.dvlpr/unc-path"
π€ΉπΌ 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
import { isValid } from '@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
import { parse } from '@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: '',
}
*/
πͺͺ License
Licensed under the MIT license which is available here, MIT license.
𧬠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. π
Provided by Igor DimitrijeviΔ (@igorskyflyer).