diff --git a/index.js b/index.js index 9123337..fde1e93 100644 --- a/index.js +++ b/index.js @@ -336,12 +336,14 @@ async function fastifyStatic (fastify, opts) { }) } } else { - const globPattern = '**' + const globPattern = '**/**' const indexDirs = new Map() const routes = new Set() + const winSeparatorRegex = new RegExp(`\\${path.win32.sep}`, 'g') + for (const rootPath of Array.isArray(sendOptions.root) ? sendOptions.root : [sendOptions.root]) { - const files = await glob(path.join(rootPath, globPattern), { follow: true, nodir: true, dot: opts.serveDotFiles }) + const files = await glob(path.join(rootPath, globPattern).replace(winSeparatorRegex, path.posix.sep), { follow: true, nodir: true, dot: opts.serveDotFiles }) const indexes = typeof opts.index === 'undefined' ? ['index.html'] : [].concat(opts.index) for (let file of files) {