oyvindkinsey/easyXDM

url is undefined or empty with Godaddy html element

cblaze22 opened this issue · 2 comments

I am getting an error in Godaddy, which I have never had an issue before. Below is the log output and the URL to the actual page.

https://okfadeawayhoops.com/exposure-testing

I believe the code is below

<script type="text/javascript">
            
            function clearCache(url) {
                return url + (url.indexOf('?') > -1 ? '&' : '?');
            }

            var iframe;
            var socket = new easyXDM.Socket({
                onReady: function () {
                    iframe = document.createElement("iframe");
                    iframe.frameBorder = 0;
                    iframe.allowtransparency = true;
                    iframe.scrolling = 'no';
                    document.body.appendChild(iframe);
                    iframe.src = clearCache(easyXDM.query.url);
                },
                onMessage: function (url, origin) {
                    iframe.src = clearCache(url);
                }
            });

        </script>
exposure.widgets.js:1008  - 15:39:07.246:easyXDM.Socket: constructor
exposure.widgets.js:1008  - 15:39:07.246:{Private}: preparing transport stack
exposure.widgets.js:1008  - 15:39:07.247:{Private}: resolved url 'https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue'
exposure.widgets.js:1008  - 15:39:07.248:{Private}: selecting protocol: 1
exposure.widgets.js:1008  - 15:39:07.248:easyXDM.stack.PostMessageTransport: constructor
exposure.widgets.js:1008  - 15:39:07.248:easyXDM.stack.QueueBehavior: constructor
exposure.widgets.js:1008  - 15:39:07.248:easyXDM.stack.PostMessageTransport: init
exposure.widgets.js:1008  - 15:39:07.248:{Private}: adding listener message
exposure.widgets.js:1008  - 15:39:07.248:{Private}: creating frame: https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1
exposure.widgets.js:1008  - 15:39:07.249:{Private}: HAS_NAME_PROPERTY_BUG: false
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.841: easyXDM present on 'https://basketball.exposureevents.com/widgets/intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: easyXDM.Socket: constructor
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: {Private}: preparing transport stack
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.844: {Private}: using parameters from query
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.845: easyXDM.stack.PostMessageTransport: constructor
easyXDM.debug.js:963 basketball.exposureevents.com - 15:39:07.846: easyXDM.stack.QueueBehavior: constructor
easyXDM.debug.js:303 Uncaught Error: url is undefined or empty
    at getLocation (easyXDM.debug.js:303)
    at new easyXDM.Socket (easyXDM.debug.js:1296)
    at intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1:45
getLocation @ easyXDM.debug.js:303
easyXDM.Socket @ easyXDM.debug.js:1296
(anonymous) @ intermediate?url=https%3A%2F%2Fbasketball.exposureevents.com%2Fwidgets%2Fv1%2Fevents%3Fseasonid%3D906079%26organizationid%3D19409%26responsive%3Dtrue&xdm_e=&xdm_c=default4637&xdm_p=1:45
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:{Private}: firing dom_onReady
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:... deferred messages ...
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.847:easyXDM.Socket: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:{Private}: preparing transport stack
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:{Private}: using parameters from query
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:easyXDM.stack.PostMessageTransport: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:easyXDM.stack.QueueBehavior: constructor
easyXDM.debug.js:1008 basketball.exposureevents.com - 15:39:07.848:... end of deferred messages ..```

You'll need to add more details, such as which browsers you've tested in.

That said, I am not at all likely to have time debugging this.

I was able to get around this.

The fix for the Godaddy HTML element is below. We need to use a valid URL instead of the "about" option.

function getLocation(url){
    if (!url) {
        throw new Error("url is undefined or empty");
    }
    if (/^file/.test(url)) {
        throw new Error("The file:// protocol is not supported");
    }

    if (/^about/.test(url)) {
        url = window.top.location.href.toLowerCase().match(reURI);
    }

    var m = url.toLowerCase().match(reURI);
    var proto = m[2], domain = m[3], port = m[4] || "";
    if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
        port = "";
    }

    return proto + "//" + domain + port;
}

This is for Godaddy specifically trying to update it's own iframe height dyanmically, otherwise a set height will be set on the iframe.

function _window_onMessage(event){
        var origin = _getOrigin(event);
        trace("received message '" + event.data + "' from " + origin);
        if (typeof (event.data) == "string") {
        if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
            pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
        }
        }
    }