url-or-path
v2.3.2
Published
Convert between file URL and path.
Downloads
286,186
Readme
url-or-path
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://
.