@esri/arcgis-rest-request
Version:
Common methods and utilities for @esri/arcgis-rest-js packages.
26 lines • 797 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSameOrigin = void 0;
/**
* Is the given URL the same origin as the current window?
* Used to determine if we need to do any additional cross-origin
* handling for the request.
* @param url
* @param win - optional window object to use for origin comparison
* (useful for testing)
* @returns
*/
function isSameOrigin(url, win) {
var _a;
/* istanbul ignore next */
if ((!win && !window) || !url) {
return false;
}
else {
win = win || window;
const origin = (_a = win.location) === null || _a === void 0 ? void 0 : _a.origin;
return url.startsWith(origin);
}
}
exports.isSameOrigin = isSameOrigin;
//# sourceMappingURL=isSameOrigin.js.map