From 5003e716502408c1c80937ea324835edd80accad Mon Sep 17 00:00:00 2001 From: Daniel Brain Date: Tue, 8 Jan 2019 16:36:03 -0800 Subject: [PATCH] Throw better error when domain is a regex --- src/serialize/function.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/serialize/function.js b/src/serialize/function.js index 1c9d037b..e480fb7a 100644 --- a/src/serialize/function.js +++ b/src/serialize/function.js @@ -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'; @@ -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) {