handle wasm files at other roots, preserve index on reload in mesh

This commit is contained in:
Stewart Allen 2022-10-22 11:02:02 -04:00
commit 376d9b2d67
4 changed files with 27 additions and 12 deletions

7
app.js
View file

@ -228,6 +228,7 @@ function init(mod) {
mod.add(handleSetup);
mod.add(handleOptions);
mod.add(handleWasm);
mod.add(fullpath({
"/kiri" : redir("/kiri/", 301),
"/mesh" : redir("/mesh/", 301),
@ -239,7 +240,7 @@ function init(mod) {
mod.add(handleVersion);
mod.add(prepath([
[ "/code/", handleCode ],
[ "/wasm/", handleWasm ]
// [ "/wasm/", handleWasm ]
]));
mod.add(fixedmap("/api/", api));
if (debug) {
@ -499,12 +500,12 @@ function handleOptions(req, res, next) {
}
function handleWasm(req, res, next) {
let [root, file] = req.app.path.split('/').slice(1);
let file = req.app.path.split('/').pop();
let ext = (file || '').split('.')[1];
let path = `${dir}/src/wasm/${file}`;
let mod = lastmod(path);
if (root === 'wasm' && ext === 'wasm' && mod) {
if (ext === 'wasm' && mod) {
let imd = ifModifiedDate(req);
if (imd && mod <= imd) {
res.writeHead(304, "Not Modified");