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
(alias toUrl(urlOrPath)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(object)
Check if object
is a URL
instance of file://
string.
isUrlInstance(object)
Check if object
is a URL
instance.
isUrlString(object)
Check if object
is a file://
string