4.0.0 • Published 3 years ago

file-url v4.0.0

Weekly downloads
127,915
License
MIT
Repository
github
Last release
3 years ago

file-url

Convert a file path to a file url: unicorn.jpgfile:///Users/sindresorhus/unicorn.jpg

Install

$ npm install file-url

Usage

import fileUrl from 'file-url';

fileUrl('unicorn.jpg');
//=> 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg'

fileUrl('/Users/pony/pics/unicorn.jpg');
//=> 'file:///Users/pony/pics/unicorn.jpg'

fileUrl('unicorn.jpg', {resolve: false});
//=> 'file:///unicorn.jpg'

API

fileUrl(filePath, options?)

Returns the filePath converted to a file URL.

filePath

Type: string

File path to convert.

options

Type: object

resolve

Type: boolean\ Default: true

Passing false will make it not call path.resolve() on the path.

Related

4.0.0

3 years ago

3.0.0

5 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

8 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.1.0

10 years ago