From 98c40256588b88f5c82c7e092bd8b927cc16ddc8 Mon Sep 17 00:00:00 2001 From: keithlee96 Date: Mon, 15 May 2023 20:25:28 +1000 Subject: [PATCH] Make it so tha Restify default's are observed. This makes the behaviour match what is stated in the docs. If a default is specified and the file does not exist, attempt to load the default file. http://restify.com/docs/plugins-api/#servestatic --- lib/plugins/static.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/plugins/static.js b/lib/plugins/static.js index 0fa6babe..dda46f28 100644 --- a/lib/plugins/static.js +++ b/lib/plugins/static.js @@ -189,6 +189,10 @@ function serveStatic(options) { } } + if (opts.default && !fs.existsSync(file)){ + file = path.join(opts.directory, decodeURIComponent(opts.default)); + } + if (req.method !== 'GET' && req.method !== 'HEAD') { next(new MethodNotAllowedError('%s', req.method)); return;