diff options
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) { |