UNPKG

@bigfishtv/cockpit

Version:

27 lines (23 loc) 854 B
'use strict'; exports.__esModule = true; exports.default = isCrossDomain; var originAnchor = document.createElement('a'); originAnchor.href = window.location.href; // from jquery source code function isCrossDomain(url) { var urlAnchor = document.createElement('a'); // Support: IE <=8 - 11, Edge 12 - 15 // IE throws exception on accessing the href property if url is malformed, // e.g. http://example.com:80x/ try { urlAnchor.href = url; // Support: IE <=8 - 11 only // Anchor's host property isn't correctly set when s.url is relative urlAnchor.href = urlAnchor.href; return originAnchor.protocol + '//' + originAnchor.host !== urlAnchor.protocol + '//' + urlAnchor.host; } catch (e) { // If there is an error parsing the URL, assume it is crossDomain, // it can be rejected by the transport if it is invalid return true; } }