Previously I posted issue #233 , but now I think that is not about absolute path/relative path, but the way this middleware works.
The goal may be achieved by using the middleware like this:
app.use('/', ecstatic({.., baseDir: "a"}));,
However, if I use it like this:
app.use('/a', ecstatic({.., baseDir: "a"})); //no matter whether baseDir is set,
it does not work correctly as I addressed in #233 , but using a middleware like that is quite common in express apps.
Think a little further, due to express's mounting feature, as stated in req.originalUrl, baseDir might be unnecessary at the 1st place. The user can just mount the ecstatic at the path they want, and let express strip the base for you:
app.use('/a', ecstatic({..}));
This works better, because this makes the middleware more portable, in the sense that the middleware does not need to know which path is it working on. The middleware can just assume the req.url contains barely the file path, which simplifies things a lot.
How do you think? @jfhbrook
Previously I posted issue #233 , but now I think that is not about absolute path/relative path, but the way this middleware works.
The goal may be achieved by using the middleware like this:
app.use('/', ecstatic({.., baseDir: "a"}));,However, if I use it like this:
app.use('/a', ecstatic({.., baseDir: "a"})); //no matter whether baseDir is set,it does not work correctly as I addressed in #233 , but using a middleware like that is quite common in express apps.
Think a little further, due to express's mounting feature, as stated in req.originalUrl,
baseDirmight be unnecessary at the 1st place. The user can just mount the ecstatic at the path they want, and let express strip the base for you:app.use('/a', ecstatic({..}));This works better, because this makes the middleware more portable, in the sense that the middleware does not need to know which path is it working on. The middleware can just assume the
req.urlcontains barely the file path, which simplifies things a lot.How do you think? @jfhbrook