Skip to content

Commit

Permalink
Throw better error when domain is a regex
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepnume committed Jan 9, 2019
1 parent 0b43dcb commit 5003e71
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/serialize/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { matchDomain, getDomain, type CrossDomainWindowType, type DomainMatcher } from 'cross-domain-utils/src';
import { ZalgoPromise } from 'zalgo-promise/src';
import { once, uniqueID } from 'belter/src';
import { once, uniqueID, isRegex } from 'belter/src';
import { serializeType, type CustomSerializedType } from 'universal-serialize/src';

import { MESSAGE_NAME, WILDCARD, SERIALIZATION_TYPE } from '../conf';
Expand Down Expand Up @@ -35,7 +35,8 @@ const listenForFunctionCalls = once(() => {
let { proxy, domain, val } = meth;

if (!matchDomain(domain, origin)) {
throw new Error(`Method '${ data.name }' domain ${ JSON.stringify(meth.domain) } does not match origin ${ origin } in ${ getDomain(window) }`);
// $FlowFixMe
throw new Error(`Method '${ data.name }' domain ${ JSON.stringify(isRegex(meth.domain) ? meth.domain.source : meth.domain) } does not match origin ${ origin } in ${ getDomain(window) }`);
}

if (proxy) {
Expand Down

0 comments on commit 5003e71

Please # to comment.