file-url
Convert a file path to a file url: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`
Last updated 6 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install file-url 
SYNC missed versions from official npm registry.

file-url

Convert a file path to a file url: unicorn.jpg → file:///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

Current Tags

  • 4.0.0                                ...           latest (6 years ago)

9 Versions

  • 4.0.0                                ...           6 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.2                                ...           10 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 21
Today 0
This Week 0
This Month 11
Last Day 0
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE