@fastify/static
Advanced tools
Comparing version 6.10.0 to 6.10.1
25
index.js
'use strict' | ||
const path = require('path') | ||
const url = require('url') | ||
const statSync = require('fs').statSync | ||
@@ -17,2 +18,3 @@ const { PassThrough } = require('readable-stream') | ||
async function fastifyStatic (fastify, opts) { | ||
opts.root = normalizeRoot(opts.root) | ||
checkRootPathForErrors(fastify, opts.root) | ||
@@ -398,2 +400,25 @@ | ||
} | ||
function normalizeRoot (root) { | ||
if (root === undefined) { | ||
return root | ||
} | ||
if (root instanceof URL && root.protocol === 'file:') { | ||
return url.fileURLToPath(root) | ||
} | ||
if (Array.isArray(root)) { | ||
const result = [] | ||
for (let i = 0, il = root.length; i < il; ++i) { | ||
if (root[i] instanceof URL && root[i].protocol === 'file:') { | ||
result.push(url.fileURLToPath(root[i])) | ||
} else { | ||
result.push(root[i]) | ||
} | ||
} | ||
return result | ||
} | ||
return root | ||
} | ||
function checkRootPathForErrors (fastify, rootPath) { | ||
@@ -400,0 +425,0 @@ if (rootPath === undefined) { |
{ | ||
"name": "@fastify/static", | ||
"version": "6.10.0", | ||
"version": "6.10.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 not supported yet
Sorry, the diff of this file is too big to display
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
5052
357559