Skip to content

Commit 621fdf2

Browse files
Add comments to explain global exposing code
1 parent ca54507 commit 621fdf2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

injected/src/trackers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { getGlobal } from './utils.js';
44
* Check if the current document origin is on the tracker list, using the provided lookup trie.
55
* @param {object} trackerLookup Trie lookup of tracker domains
66
* @returns {boolean} True iff the origin is a tracker.
7+
*
8+
* Note: getGlobal() is in testing to get the global object,
9+
* it's a work around for ESM modules are essentially singletons preventing overriding of global variables.
710
*/
811
export function isTrackerOrigin(trackerLookup, originHostname = getGlobal().document.location.hostname) {
912
const parts = originHostname.split('.').reverse();

injected/src/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export function setGlobal(globalObjIn) {
4949
Error = globalObj.Error;
5050
}
5151

52+
/**
53+
* Used for testing to allow other files to override the globals used within this file.
54+
* @returns {globalThis} the global object
55+
*/
5256
export function getGlobal() {
5357
return globalObj;
5458
}

0 commit comments

Comments
 (0)