diff options
author | hackademix | 2018-09-09 14:57:09 +0200 |
---|---|---|
committer | hackademix | 2018-09-09 14:57:09 +0200 |
commit | 002c8f8b67f863bb62eee5a9c8244ff42d890067 (patch) | |
tree | 668f7cd526c8c3f674ca56093a882aeef91a0af9 /src/lib | |
parent | c5cbb8abfc7c19e019f0fd8971090258b0af499b (diff) | |
download | noscript-002c8f8b67f863bb62eee5a9c8244ff42d890067.tar.gz noscript-002c8f8b67f863bb62eee5a9c8244ff42d890067.tar.xz noscript-002c8f8b67f863bb62eee5a9c8244ff42d890067.zip |
Message loops checks coping with multiple options window.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Messages.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/Messages.js b/src/lib/Messages.js index 11b9010..1c11870 100644 --- a/src/lib/Messages.js +++ b/src/lib/Messages.js @@ -24,10 +24,12 @@ answers.length === 1 ? answers.pop(): Promise.all(answers) ); } - let context = typeof window === "object" && window.location.href || null; + let context = typeof window === "object" && window.location.href || "?"; let originalSender = __meta.originalSender || sender; - if (context === originalSender.url || context === sender.url) { - throw new Error("Message %s (%o) looping to its sender (%s)", name, msg, context); + let {url} = originalSender; + + if (url && context.replace(/[?#].*/, '') === url.replace(/[?#].*/, '')) { + throw new Error(`Message ${name} ${JSON.stringify(msg)} looping to its sender (${context})`); } console.debug("Warning: no handler for message %o in context %s", msg, context); if (originalSender.tab && originalSender.tab.id) { |