diff --git a/src/js/html-filtering.js b/src/js/html-filtering.js
index 58a23b14e..d1118ba46 100644
--- a/src/js/html-filtering.js
+++ b/src/js/html-filtering.js
@@ -356,7 +356,7 @@
);
if ( details.entity !== '' ) {
filterDB.retrieve(
- `${hostname.slice(0, -details.domain)}${details.entity}`,
+ `${hostname.slice(0, -details.domain.length)}${details.entity}`,
[ plains, exceptions, procedurals, exceptions ]
);
}
diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js
index 7c2b48903..7477960e4 100644
--- a/src/js/scriptlet-filtering.js
+++ b/src/js/scriptlet-filtering.js
@@ -369,7 +369,7 @@
);
if ( request.entity !== '' ) {
scriptletDB.retrieve(
- `${hostname.slice(0, -request.domain)}${request.entity}`,
+ `${hostname.slice(0, -request.domain.length)}${request.entity}`,
[ scriptlets, exceptions ]
);
}