Socket
Socket
Sign inDemoInstall

fastify-static

Package Overview
Dependencies
Maintainers
13
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-static - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

test/static-pre-compressed/empty/.gitkeep

28

index.js

@@ -84,2 +84,8 @@ 'use strict'

if (encodingExt) {
if (pathname.endsWith('/')) {
pathname = findIndexFile(pathname, options.root, options.index)
if (!pathname) {
return reply.callNotFound()
}
}
pathnameForSend = pathname + '.' + encodingExt

@@ -128,2 +134,3 @@ }

if (encodingExt) {
reply.header('content-type', getContentType(pathname))
reply.header('content-encoding', encodingExt)

@@ -381,2 +388,23 @@ }

function getContentType (path) {
const type = send.mime.lookup(path)
const charset = send.mime.charsets.lookup(type)
if (!charset) {
return type
}
return `${type}; charset=${charset}`
}
function findIndexFile (pathname, root, indexFiles = ['index.html']) {
return indexFiles.find(filename => {
const p = path.join(root, pathname, filename)
try {
const stats = statSync(p)
return !stats.isDirectory()
} catch (e) {
return false
}
})
}
// Adapted from https://github.com/fastify/fastify-compress/blob/fa5c12a5394285c86d9f438cb39ff44f3d5cde79/index.js#L442

@@ -383,0 +411,0 @@ function checkEncodingHeaders (headers, checked) {

2

package.json
{
"name": "fastify-static",
"version": "4.2.0",
"version": "4.2.1",
"description": "Plugin for serving static files as fast as possible.",

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

Sorry, the diff of this file is too big to display

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