@fastify/static
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -61,3 +61,3 @@ // Definitions by: Jannik <https://github.com/jannikkeye> | ||
immutable?: boolean; | ||
index?: string[] | false; | ||
index?: string[] | string | false; | ||
lastModified?: boolean; | ||
@@ -92,3 +92,3 @@ maxAge?: string | number; | ||
immutable?: boolean; | ||
index?: string[] | false; | ||
index?: string[] | string | false; | ||
lastModified?: boolean; | ||
@@ -95,0 +95,0 @@ maxAge?: string | number; |
23
index.js
@@ -329,3 +329,3 @@ 'use strict' | ||
} else { | ||
const globPattern = '**/*' | ||
const globPattern = '**/**' | ||
const indexDirs = new Map() | ||
@@ -453,11 +453,14 @@ const routes = new Set() | ||
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 | ||
} | ||
}) | ||
if (Array.isArray(indexFiles)) { | ||
return indexFiles.find(filename => { | ||
const p = path.join(root, pathname, filename) | ||
try { | ||
const stats = statSync(p) | ||
return !stats.isDirectory() | ||
} catch (e) { | ||
return false | ||
} | ||
}) | ||
} | ||
return false | ||
} | ||
@@ -464,0 +467,0 @@ |
{ | ||
"name": "@fastify/static", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Plugin for serving static files as fast as possible.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -162,3 +162,3 @@ # @fastify/static | ||
If set to `false`, `@fastify/static` globs the filesystem for all defined | ||
files in the served folder (`${root}/**/*`), and just creates the routes needed for | ||
files in the served folder (`${root}/**/**`), and just creates the routes needed for | ||
those and it will not serve the newly added file on the filesystem. | ||
@@ -165,0 +165,0 @@ |
@@ -31,3 +31,4 @@ import fastify from 'fastify' | ||
expectError<FastifyStaticOptions>({ | ||
wlidcard: '**/*' | ||
root: '', | ||
wildcard: '**/**' | ||
}) | ||
@@ -107,1 +108,12 @@ | ||
}) | ||
const defaultIndexApp = fastify() | ||
options.index = 'index.html' | ||
defaultIndexApp | ||
.register(fastifyStatic, options) | ||
.after(() => { | ||
defaultIndexApp.get('/', (request, reply) => { | ||
reply.send('<h1>fastify-static</h1>') | ||
}) | ||
}) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
356890
47
4539