url-or-path
TypeScript icon, indicating that this package has built-in type declarations

2.3.2 • Public • Published

url-or-path

Build Status Coverage Npm Version MIT License

Convert between file URL and path.

Install

yarn add url-or-path

Usage

import {toUrl, toPath} from 'url-or-path'

console.log(toUrl(urlOrPath))
//=> URL {/* ... */}

console.log(toPath(urlOrPath))
//=> 'path/to/file'

API

toUrl(urlOrPath)(alias toURL)

Type: string | URL

Returns a URL object of given URL or path string.

toPath(urlOrPath)

Type: string | URL

Returns path string of given URL or path string.

toDirectory(urlOrPath)

Type: string | URL

Same as toUrl, but the result URL always ends with /.

isUrl(value)(alias isURL)

Check if value is a URL instance or a string starts with file://.

isUrlInstance(value)(alias isURLInstance)

Check if value is a URL instance.

isUrlString(value)(alias isURLString)

Check if value is a string starts with file://.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.3.210,289latest

Version History

VersionDownloads (Last 7 Days)Published
2.3.210,289
2.3.147
2.3.035,329
2.2.00
2.1.023,074
2.0.00
1.1.00
1.0.40
1.0.20
1.0.10
1.0.00
0.0.20
0.0.10
0.0.00

Package Sidebar

Install

npm i url-or-path

Weekly Downloads

68,739

Version

2.3.2

License

MIT

Unpacked Size

8.67 kB

Total Files

6

Last publish

Collaborators

  • fisker