🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

file-url

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

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`

3.0.0
Source
npm
Version published
Weekly downloads
646K
-10.06%
Maintainers
1
Weekly downloads
 
Created

What is file-url?

The file-url npm package is a utility that converts file paths to file URLs. This can be particularly useful when working with file systems in Node.js and needing to generate URLs that can be used in web contexts.

What are file-url's main functionalities?

Convert file path to file URL

This feature allows you to convert a given file path to a file URL. The resulting URL can be used in web contexts where a file URL is required.

const fileUrl = require('file-url');
const url = fileUrl('/path/to/file');
console.log(url); // Outputs: 'file:///path/to/file'

Convert file path to file URL with custom options

This feature allows you to convert a file path to a file URL with additional options. For example, the 'resolve' option can be used to resolve the file path to an absolute path before converting it to a URL.

const fileUrl = require('file-url');
const url = fileUrl('/path/to/file', { resolve: true });
console.log(url); // Outputs: 'file:///absolute/path/to/file'

Other packages similar to file-url

Keywords

file

FAQs

Package last updated on 15 Apr 2019

Did you know?

Socket

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