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.0.1 to 1.1.0

18

cli.js

@@ -6,13 +6,11 @@ #!/usr/bin/env node

var cli = meow({
help: [
'Usage',
' $ file-url [path]',
'',
'Example',
' $ file-url',
' file:///Users/sindresorhus/dev/file-url'
].join('\n')
});
var cli = meow([
'Usage',
' $ file-url [path]',
'',
'Example',
' $ file-url',
' file:///Users/sindresorhus/dev/file-url'
]);
console.log(fileUrl(cli.input[0] || process.cwd()));
'use strict';
var path = require('path');
module.exports = function (str) {
module.exports = function (str, options) {
if (typeof str !== 'string') {

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

var pathName = path.resolve(str).replace(/\\/g, '/');
options = options || {};
var pathName = str;
if (options.resolve !== false) {
pathName = path.resolve(str);
}
pathName = pathName.replace(/\\/g, '/');
// Windows drive letter must be prefixed with a slash

@@ -13,0 +21,0 @@ if (pathName[0] !== '/') {

{
"name": "file-url",
"version": "1.0.1",
"version": "1.1.0",
"description": "Convert a path to a file url: unicorn.jpg → file:///Users/sindresorhus/unicorn.jpg",

@@ -17,3 +17,3 @@ "license": "MIT",

"scripts": {
"test": "mocha"
"test": "xo && mocha"
},

@@ -37,7 +37,8 @@ "files": [

"dependencies": {
"meow": "^3.1.0"
"meow": "^3.7.0"
},
"devDependencies": {
"mocha": "*"
"mocha": "*",
"xo": "*"
}
}

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

```js
var fileUrl = require('file-url');
const fileUrl = require('file-url');
fileUrl('unicorn.jpg');
//=> file:///Users/sindresorhus/dev/file-url/unicorn.jpg
//=> 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg'
fileUrl('/Users/pony/pics/unicorn.jpg');
//=> file:///Users/pony/pics/unicorn.jpg
//=> 'file:///Users/pony/pics/unicorn.jpg'
// passing {resolve: false} will make it not call path.resolve() on the path
fileUrl('unicorn.jpg', {resolve: false});
//=> 'file:///unicorn.jpg'
```

@@ -25,0 +29,0 @@

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