Socket
Socket
Sign inDemoInstall

file-url

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    file-url

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


Version published
Weekly downloads
449K
increased by0.09%
Maintainers
1
Install size
4.88 kB
Created
Weekly downloads
 

Readme

Source

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.

  • file-url-cli - CLI for this module

Keywords

FAQs

Last updated on 07 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc