devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
49 lines (46 loc) • 1.45 kB
JavaScript
/**
* DevExtreme (cjs/__internal/data/m_endpoint_selector.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _errors = _interopRequireDefault(require("../../core/errors"));
var _window = require("../../core/utils/window");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const window = (0, _window.getWindow)();
let IS_WINJS_ORIGIN;
let IS_LOCAL_ORIGIN;
function isLocalHostName(url) {
return /^(localhost$|127\.)/i.test(url)
}
const EndpointSelector = function(config) {
this.config = config;
IS_WINJS_ORIGIN = "ms-appx:" === window.location.protocol;
IS_LOCAL_ORIGIN = isLocalHostName(window.location.hostname)
};
EndpointSelector.prototype = {
urlFor(key) {
const bag = this.config[key];
if (!bag) {
throw _errors.default.Error("E0006")
}
if (bag.production) {
if (IS_WINJS_ORIGIN && !Debug.debuggerEnabled || !IS_WINJS_ORIGIN && !IS_LOCAL_ORIGIN) {
return bag.production
}
}
return bag.local
}
};
var _default = exports.default = EndpointSelector;