resolveOrigin = function resolveOrigin(url) {
    var a = document.createElement('a');
    a.href = url;
    var protocol = a.protocol.length > 4 ? a.protocol : window.location.protocol;
    var host = a.host.length ? a.port === '80' || a.port === '443' ? a.hostname : a.host : window.location.host;
    return a.origin || protocol + "//" + host;
  }
Takes a URL and returns the origin
@param  {String} url The full URL being requested
@return {String}     The URLs origin