Skip to content

[v7] Unexpected console warning #103

Closed
@A-Shleifman

Description

@A-Shleifman

Thank you very much for this package! I wanted to share an unexpected behavior I encountered.

My setup

  • host domain: host.com
  • iframe domain: iframe.com
  • penpal v7
const connection = connect({
  messenger: new WindowMessenger({
    remoteWindow: iframe.contentWindow,
    allowedOrigins: [new RegExp(`^https://iframe.com$`)],
  }),
  methods: hostApiMethods,
});

I noticed that when a RegExp is passed to allowedOrigins there are no warnings in the console, however when the same origin is passed as a string https://iframe.com, penpal is displaying the following warning:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://iframe.com') does not match the recipient window's origin ('https://host.com').

Unless I'm missing something, penpal shouldn't be comparing the origin to https://host.com at all in this case. Despite the warning, the connection is happening in both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions