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

hyperdrive-http

Package Overview
Dependencies
Maintainers
8
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperdrive-http - npm Package Compare versions

Comparing version 4.2.2 to 4.3.0

test/404.html

37

index.js

@@ -36,3 +36,3 @@ var toHTML = require('directory-index-html')

archive.stat(name, function (err, st) {
if (err) return onerror(res, 404, err)
if (err) return on404(archive, res, req)

@@ -62,2 +62,17 @@ if (st.isDirectory()) {

function on404 (archive, req, res) {
getManifest(archive, function (err, parsed) {
if (err) return onerror(res, 404, err)
var fallbackPage = parsed.fallback_page
if (!fallbackPage) return onerror(res, 404, new Error('Not Found, No Fallback'))
archive.stat(fallbackPage, function (err) {
if (err) return onerror(res, 404, err)
onfile(archive, fallbackPage, req, res)
})
})
}
function ondirectory (archive, name, req, res, opts) {

@@ -96,3 +111,3 @@ archive.stat(name + 'index.html', function (err) {

var footer = opts.footer ? opts.footer + ' Archive version: ' + archive.version : null
var footer = opts.footer ? 'Archive version: ' + archive.version : null
var html = toHTML({directory: name, script: (!opts.live || archive._checkout) ? null : script, footer: footer}, entries)

@@ -110,2 +125,19 @@ res.setHeader('Content-Type', 'text/html; charset=utf-8')

function getManifest (archive, cb) {
archive.readFile('/dat.json', 'utf-8', function (err, data) {
if (err) cb(err)
try {
var parsed = JSON.parse(data)
} catch (e) {
return cb(err)
}
if (!parsed || Array.isArray(parsed) || (typeof parsed !== 'object')) {
return cb(new Error('Invalid dat.json format'))
}
cb(null, parsed)
})
}
function waitFor (archive, until, cb) { // this feels a bit hacky, TODO: make less complicated?

@@ -121,2 +153,3 @@ archive.setMaxListeners(0)

res.statusCode = status
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
res.end(err.stack)

@@ -123,0 +156,0 @@ }

2

package.json
{
"name": "hyperdrive-http",
"version": "4.2.2",
"version": "4.3.0",
"description": "Handle Hyper[drive|core] HTTP Requests",

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

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