From 71aab77f4f9d8e4079d0c5ac933867c1a8712f46 Mon Sep 17 00:00:00 2001 From: Changzhe Ma Date: Mon, 20 Jan 2020 16:06:32 +0800 Subject: [PATCH] #289 fix a bug on load brainbrowser worker on desktop. --- src/brainbrowser/lib/utils.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/brainbrowser/lib/utils.js b/src/brainbrowser/lib/utils.js index 858076f1..7b80bd58 100644 --- a/src/brainbrowser/lib/utils.js +++ b/src/brainbrowser/lib/utils.js @@ -140,10 +140,9 @@ let import_url = document.location.origin; if (protocal === 'file:') { let href = document.location.href; - if (href.endsWith('/')) { - href = href.substring(0, href.lastIndexOf('/')); - } - href = href.substring(0, href.lastIndexOf('/') + 1); + const regex = /^.*resources\/app\.asar\/dist\//; + const matchResult = href.match(regex); + href = matchResult && matchResult.length > 0 && matchResult[0] ? matchResult[0] : href; import_url = href + worker_dir; } else { if (!import_url.endsWith('/') && worker_dir[0] !== '/') {