From a42513aa2f85651955e4431ed7aa9d78de98d13e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 4 Nov 2018 19:26:02 -0200 Subject: [PATCH] minor code review --- docs/README.md | 2 +- src/js/hntrie.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) 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 });