From 002c8f8b67f863bb62eee5a9c8244ff42d890067 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 9 Sep 2018 14:57:09 +0200 Subject: Message loops checks coping with multiple options window. --- src/lib/Messages.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib') 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) { -- cgit v1.2.3