diff --git a/docs/README.md b/docs/README.md
index af37db25f..6e0353f2d 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,3 +1,3 @@
## uBlock Origin pages
-HTML: .
\ No newline at end of file
+HTML: .
\ No newline at end of file
diff --git a/src/js/hntrie.js b/src/js/hntrie.js
index 8ba88c67b..ef66e032c 100644
--- a/src/js/hntrie.js
+++ b/src/js/hntrie.js
@@ -477,11 +477,12 @@ const hnTrieManager = {
// location, and consequently so will be the related WASM file.
let workingDir;
{
- const url = document.currentScript.src;
- const match = /[^\/]+$/.exec(url);
- workingDir = match !== null
- ? url.slice(0, match.index)
- : '';
+ const url = new URL(document.currentScript.src);
+ const match = /[^\/]+$/.exec(url.pathname);
+ if ( match !== null ) {
+ url.pathname = url.pathname.slice(0, match.index);
+ }
+ workingDir = url.href;
}
const memory = new WebAssembly.Memory({ initial: 1 });