/*global define*/
define(function() {
    "use strict";

    var a;

    /**
     * Given a URL, determine whether that URL is considered cross-origin to the current page.
     *
     * @private
     */
    var isCrossOriginUrl = function(url) {
        if (typeof a === 'undefined') {
            a = document.createElement('a');
        }

        var location = window.location;
        a.href = url;
        a.href = a.href; // IE only absolutizes href on get, not set

        // host includes both hostname and port if the port is not standard
        return a.protocol !== location.protocol || a.host !== location.host;
    };

    return isCrossOriginUrl;
});
/*global define*/
define(function() {
    "use strict";

    var a;

    /**
     * Given a URL, determine whether that URL is considered cross-origin to the current page.
     *
     * @private
     */
    var isCrossOriginUrl = function(url) {
        if (typeof a === 'undefined') {
            a = document.createElement('a');
        }

        // copy window location into the anchor to get consistent results
        // when the port is default for the protocol (e.g. 80 for HTTP)
        a.href = window.location.href;

        // host includes both hostname and port if the port is not standard
        var host = a.host;
        var protocol = a.protocol;

        a.href = url;
        a.href = a.href; // IE only absolutizes href on get, not set

        return protocol !== a.protocol || host !== a.host;
    };

    return isCrossOriginUrl;
});
Put both the window URL and the test URL through an anchor.
Put both the window URL and the test URL through an anchor.

Fixes an inconsistency in IE between a.href and window.location about whether default ports are included or not.
