How to use the cross-domain-utils/src.getDomainFromUrl function in cross-domain-utils

To help you get started, we’ve selected a few cross-domain-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / zoid / dist / module / component / component / index.js View on Github external
Component.prototype.getInitialDomain = function getInitialDomain(props) {
        if (typeof this.domain === 'string') {
            // $FlowFixMe
            return this.domain;
        }

        var env = props.env || this.defaultEnv;
        // $FlowFixMe
        if (env && _typeof(this.domain) === 'object' && !isRegex(this.domain) && this.domain[env]) {
            return this.domain[env];
        }

        return getDomainFromUrl(this.getUrl(props));
    };
github krakenjs / zoid / src / component / component.js View on Github external
getChildDomain(props : PropsType<p>) : string {
        if (this.domain &amp;&amp; typeof this.domain === 'string') {
            return this.domain;
        }

        return getDomainFromUrl(this.getUrl(props));
    }
</p>
github krakenjs / post-robot / src / bridge / common.js View on Github external
export function getBridgeName(domain : string) : string {

    domain = domain || getDomainFromUrl(domain);

    const sanitizedDomain = domain.replace(/[^a-zA-Z0-9]+/g, '_');

    const id = `${ BRIDGE_NAME_PREFIX }_${ sanitizedDomain }`;

    return id;
}
github krakenjs / zoid / src / component / parent / index.js View on Github external
tasks.openBridge = ZalgoPromise.all([ tasks.open, tasks.buildUrl ]).then(([ proxyWin, url ]) => {
                return this.openBridge(proxyWin, getDomainFromUrl(url), context);
            });
github krakenjs / post-robot / src / bridge / parent.js View on Github external
export function openBridge(url : string, domain : string) : ZalgoPromise {
    const bridges = globalStore('bridges');
    const bridgeFrames = globalStore('bridgeFrames');
    
    domain = domain || getDomainFromUrl(url);
    
    return bridges.getOrSet(domain, () =&gt; ZalgoPromise.try(() =&gt; {

        if (getDomain() === domain) {
            throw new Error(`Can not open bridge on the same domain as current domain: ${ domain }`);
        }

        const name  = getBridgeName(domain);
        const frame = getFrameByName(window, name);

        if (frame) {
            throw new Error(`Frame with name ${ name } already exists on page`);
        }

        const iframe = openBridgeFrame(name, url);
        bridgeFrames.set(domain, iframe);
github krakenjs / post-robot / src / bridge / parent.js View on Github external
export function hasBridge(url : string, domain : string) : boolean {
    const bridges = globalStore('bridges');
    return bridges.has(domain || getDomainFromUrl(url));
}
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
}).then(function (win) {
            if (!bridge || !bridge.needsBridge({ win: win, domain: domain }) || bridge.hasBridge(domain, domain)) {
                return;
            }

            var bridgeUrl = _this7.component.getBridgeUrl(_this7.props);

            if (!bridgeUrl) {
                throw new Error('Bridge url and domain needed to render ' + context);
            }

            var bridgeDomain = getDomainFromUrl(bridgeUrl);
            bridge.linkUrl(win, domain);
            return bridge.openBridge(bridgeUrl, bridgeDomain);
        });
    };
github krakenjs / post-robot / src / bridge / common.js View on Github external
export function needsBridgeForDomain(domain : ?string, win : ?CrossDomainWindowType) : boolean {

    if (domain) {
        if (getDomain() !== getDomainFromUrl(domain)) {
            return true;
        }
    } else if (win) {
        if (!isSameDomain(win))  {
            return true;
        }
    }

    return false;
}
github krakenjs / post-robot / src / bridge / parent.js View on Github external
export function linkUrl(win : CrossDomainWindowType, url : string) {
    linkWindow({ win, domain: getDomainFromUrl(url) });
}