An open API service indexing awesome lists of open source software.

https://github.com/igorskyflyer/npm-unc-path

πŸ₯½ Provides ways of parsing UNC paths and checking whether they are valid. 🎱
https://github.com/igorskyflyer/npm-unc-path

back-end biome filesystem igorskyflyer javascript node nodejs npm parser path typescript unc vitest

Last synced: about 2 months ago
JSON representation

πŸ₯½ Provides ways of parsing UNC paths and checking whether they are valid. 🎱

Awesome Lists containing this project

README

          

# UNC Path


πŸ₯½ Provides ways of parsing UNC paths and checking whether they are valid. 🎱



UNC Path








πŸ’– Support further development


I work hard for every project, including this one and your support means a lot to me!


Consider buying me a coffee. β˜•


Thank you for supporting my efforts! πŸ™πŸ˜Š





Donate to igorskyflyer




@igorskyflyer








## πŸ•΅πŸΌ Usage

Install it by executing:

```shell
npm i "@igor.dvlpr/unc-path"
```


## 🀹🏼 API

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


Signature

```ts
isValid(path): boolean
```


Parameters

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


#### Example

```ts
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

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


Signature

```ts
parse(path): Object
```


Parameters

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


#### Example

```ts
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](https://github.com/igorskyflyer/npm-unc-path/blob/main/LICENSE).

---

## 🧬 Related

[@igor.dvlpr/encode-entities](https://www.npmjs.com/package/@igor.dvlpr/encode-entities)

> _πŸƒβ€β™‚οΈ Fast and simple Map and RegExp based HTML entities encoder. 🍁_

[@igor.dvlpr/regkeys](https://www.npmjs.com/package/@igor.dvlpr/regkeys)

> _πŸ“š An NPM package for fetching Windows registry keys. πŸ—_

[@igor.dvlpr/upath](https://www.npmjs.com/package/@igor.dvlpr/upath)

> _🎍 Provides a universal way of formatting file-paths in Unix-like and Windows operating systems as an alternative to the built-in path.normalize(). 🧬_

[@igor.dvlpr/is-rootdir](https://www.npmjs.com/package/@igor.dvlpr/is-rootdir)

> _πŸ”Ό Provides a way to check if the given path is the root drive/directory. β›”_

[@igor.dvlpr/valid-path](https://www.npmjs.com/package/@igor.dvlpr/valid-path)

> _🧰 Provides ways of testing whether a given value can be a valid file/directory name. 🏜_




>
> Provided by **Igor Dimitrijević** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).
>