make olmPath absolute if it isn't already

This commit is contained in:
Bruno Windels 2021-12-06 13:49:14 +01:00
parent 9a3f74c6fb
commit 155cd4c9bd
2 changed files with 11 additions and 2 deletions

View file

@ -80,8 +80,16 @@ function relPath(path, basePath) {
async function loadOlmWorker(config) { async function loadOlmWorker(config) {
const workerPool = new WorkerPool(config.worker, 4); const workerPool = new WorkerPool(config.worker, 4);
await workerPool.init(); await workerPool.init();
const path = relPath(config.olm.legacyBundle, config.worker); let olmPath = config.olm.legacyBundle;
await workerPool.sendAll({type: "load_olm", path}); // convert olm path to absolute path
if (!olmPath.startsWith("/")) {
olmPath = new URL(olmPath, document.location.href).pathname;
console.log("olmPath", config.olm.legacyBundle, olmPath);
}
await workerPool.sendAll({
type: "load_olm",
path: olmPath
});
const olmWorker = new OlmWorker(workerPool); const olmWorker = new OlmWorker(workerPool);
return olmWorker; return olmWorker;
} }

View file

@ -20,6 +20,7 @@ let polyfillRef;
export default { export default {
public: false, public: false,
root: "src/platform/web", root: "src/platform/web",
base: "./",
server: { server: {
hmr: false hmr: false
}, },