@fastify/static 6.7.0 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +10 -7
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -27,6 +27,10 @@ async function fastifyStatic (fastify, opts) {
27
27
  throw invalidDirListOpts
28
28
  }
29
29
 
30
+ if (opts.dotfiles === undefined) {
31
+ opts.dotfiles = 'allow'
32
+ }
33
+
30
34
  const sendOptions = {
31
35
  root: opts.root,
32
36
  acceptRanges: opts.acceptRanges,
@@ -37,8 +41,7 @@ async function fastifyStatic (fastify, opts) {
37
41
  immutable: opts.immutable,
38
42
  index: opts.index,
39
43
  lastModified: opts.lastModified,
40
- maxAge: opts.maxAge,
41
- serveDotFiles: opts.serveDotFiles ?? false
44
+ maxAge: opts.maxAge
42
45
  }
43
46
 
44
47
  const allowedPath = opts.allowedPath
@@ -337,7 +340,7 @@ async function fastifyStatic (fastify, opts) {
337
340
  const winSeparatorRegex = new RegExp(`\\${path.win32.sep}`, 'g')
338
341
 
339
342
  for (const rootPath of Array.isArray(sendOptions.root) ? sendOptions.root : [sendOptions.root]) {
340
- const files = await globPromise(path.join(rootPath, globPattern).replace(winSeparatorRegex, path.posix.sep), { nodir: true, dot: sendOptions.serveDotFiles })
343
+ const files = await globPromise(path.join(rootPath, globPattern).replace(winSeparatorRegex, path.posix.sep), { nodir: true, dot: opts.serveDotFiles })
341
344
  const indexes = typeof opts.index === 'undefined' ? ['index.html'] : [].concat(opts.index)
342
345
 
343
346
  for (let file of files) {
@@ -447,12 +450,12 @@ function checkPath (fastify, rootPath) {
447
450
  const supportedEncodings = ['br', 'gzip', 'deflate']
448
451
 
449
452
  function getContentType (path) {
450
- const type = send.mime.lookup(path)
451
- const charset = send.mime.charsets.lookup(type)
452
- if (!charset) {
453
+ const type = send.mime.getType(path)
454
+
455
+ if (!send.isUtf8MimeType(type)) {
453
456
  return type
454
457
  }
455
- return `${type}; charset=${charset}`
458
+ return `${type}; charset=UTF-8`
456
459
  }
457
460
 
458
461
  function findIndexFile (pathname, root, indexFiles = ['index.html']) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/static",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "Plugin for serving static files as fast as possible.",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "glob": "^8.0.1",
36
36
  "p-limit": "^3.1.0",
37
37
  "readable-stream": "^4.0.0",
38
- "@fastify/send": "^1.0.0"
38
+ "@fastify/send": "^2.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@fastify/compress": "^6.0.0",