Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

14

index.js
'use strict';
var path = require('path');
const path = require('path');
module.exports = function (str, options) {
module.exports = (str, opts) => {
if (typeof str !== 'string') {

@@ -9,7 +9,7 @@ throw new Error('Expected a string');

options = options || {};
opts = Object.assign({resolve: true}, opts);
var pathName = str;
let pathName = str;
if (options.resolve !== false) {
if (opts.resolve) {
pathName = path.resolve(str);

@@ -22,6 +22,6 @@ }

if (pathName[0] !== '/') {
pathName = '/' + pathName;
pathName = `/${pathName}`;
}
return encodeURI('file://' + pathName);
return encodeURI(`file://${pathName}`);
};
{
"name": "file-url",
"version": "1.1.0",
"description": "Convert a path to a file url: unicorn.jpg → file:///Users/sindresorhus/unicorn.jpg",
"version": "2.0.0",
"description": "Convert a path to a file url: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`",
"license": "MIT",

@@ -12,18 +12,12 @@ "repository": "sindresorhus/file-url",

},
"bin": "cli.js",
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "xo && mocha"
"test": "xo && ava"
},
"files": [
"cli.js",
"index.js"
],
"keywords": [
"cli-app",
"cli",
"bin",
"app",
"file",

@@ -36,9 +30,9 @@ "url",

],
"dependencies": {
"meow": "^3.7.0"
},
"devDependencies": {
"mocha": "*",
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -30,22 +30,9 @@ # file-url [![Build Status](https://travis-ci.org/sindresorhus/file-url.svg?branch=master)](https://travis-ci.org/sindresorhus/file-url)

## CLI
## Related
```
$ npm install --global file-url
```
- [file-url-cli](https://github.com/sindresorhus/file-url-cli) - CLI for this module
```
$ file-url --help
Usage
$ file-url [path]
Example
$ file-url
file:///Users/sindresorhus/dev/file-url
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc