Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-fetch

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-fetch - npm Package Compare versions

Comparing version 1.6.1 to 1.7.0

12

index.js

@@ -14,2 +14,3 @@ /* global URL */

const access = promisify(fs.access)
const stat = promisify(fs.stat)

@@ -33,2 +34,10 @@ function decodeIRI (iri, baseDir, baseURL) {

async function silentFileSize (pathname) {
try {
return (await stat(pathname)).size
} catch (err) {
return null
}
}
function response (status, body, headers) {

@@ -53,2 +62,4 @@ return {

if (method === 'GET') {
const size = await silentFileSize(pathname)
return new Promise((resolve) => {

@@ -63,2 +74,3 @@ const stream = fs.createReadStream(pathname)

resolve(response(200, stream, {
'content-length': size.toString(),
'content-type': contentTypeLookup(extension) || contentType(extension)

@@ -65,0 +77,0 @@ }))

2

package.json
{
"name": "file-fetch",
"version": "1.6.1",
"version": "1.7.0",
"description": "fetch for read and write access to the local file system",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -66,2 +66,8 @@ const fs = require('fs')

it('should set the content-length header', async () => {
const res = await fileFetch('file://' + path.join(__dirname, 'support/file.txt'))
assert.strictEqual(res.headers.get('content-length'), '4')
})
it('should read the file content with method GET', async () => {

@@ -68,0 +74,0 @@ const res = await fileFetch('file://' + path.join(__dirname, 'support/file.txt'), {

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