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.3.0 to 1.3.1

18

index.js

@@ -9,2 +9,18 @@ const fs = require('fs')

function decodeIRI (iri) {
// IRIs without file scheme are used directly
if (!iri.startsWith('file:')) {
return iri
}
const pathname = decodeURIComponent(new URL(iri).pathname)
// remove the leading slash for IRIs with file scheme and relative path
if (!iri.startsWith('file:/')) {
return pathname.split('/').slice(1).join('/')
}
return pathname
}
function text (stream) {

@@ -39,3 +55,3 @@ return new Promise((resolve, reject) => {

const pathname = iri.startsWith('file:') ? decodeURIComponent(new URL(iri).pathname) : iri
const pathname = decodeIRI(iri)

@@ -42,0 +58,0 @@ if (options.method === 'GET') {

2

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

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

@@ -85,2 +85,22 @@ const fs = require('fs')

it('should read the file content with relative URL and method GET', () => {
return fileFetch('file:./test/support/file.txt', {
method: 'GET'
}).then((res) => {
return new Promise((resolve) => {
let content = ''
res.body.on('data', (chunk) => {
content += chunk
})
res.body.on('end', () => {
assert.strictEqual(content, 'test')
resolve()
})
})
})
})
it('should give a 404 path to non-existent file (method GET)', () => {

@@ -87,0 +107,0 @@ return fileFetch('./test/support/nonexistent-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